Closed (fixed)
Project:
Services
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
21 Sep 2012 at 23:26 UTC
Updated:
29 Oct 2012 at 15:41 UTC
The services module exits without calling drupal_page_footer(), which thwarts Drupal's built-in header controls and caching ability. Since caching is one of the fundamental REST constraints, this is a significant limitation.
/admin/structure/services, add a REST service called "test"
/admin/config/development/performance, enable "cache pages for anonymous" and set "expiration of cached pages" to 1 minute
/test/node
Cache-Control: public, max-age=60
{cache_page} table is empty
Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0
Call drupal_page_footer().
Patch needs review.
N/A
Module authors must call drupal_page_is_cacheable(FALSE) in their service callbacks if responses should not be cached.
| Comment | File | Size | Author |
|---|---|---|---|
| services-drupal_set_footer-6-3-dev.patch | 432 bytes | raspberryman | |
| services-drupal_set_footer-7-3-dev.patch | 432 bytes | raspberryman |
Comments
Comment #1
kylebrowning commentedComment #2
grendzy commentedI'm using this patch on one of my projects with good results. We're getting caching within Drupal, and also downstream in the Akamai CDN. Here's a sample of the headers:
[dylan@mb ~]$ curl -k -v -s -o/dev/null -H "Pragma: akamai-x-get-cache-key" -H "Pragma: akamai-x-cache-on" -H "Pragma: akamai-x-cache-remote-on" -H "Pragma: akamai-x-get-true-cache-key" http://www.emmys.com/iphone/category.json
* About to connect() to www.emmys.com port 80 (#0)
* Trying 23.3.105.32... connected
> GET /iphone/category.json HTTP/1.1
> User-Agent: curl/7.23.1 (x86_64-apple-darwin11.2.0) libcurl/7.23.1 OpenSSL/1.0.1c zlib/1.2.7 libidn/1.22
> Host: www.emmys.com
> Accept: */*
> Pragma: akamai-x-get-cache-key
> Pragma: akamai-x-cache-on
> Pragma: akamai-x-cache-remote-on
> Pragma: akamai-x-get-true-cache-key
>
< HTTP/1.1 200 OK
< Server: Apache/2.2.3 (CentOS)
< X-Powered-By: PHP/5.2.17
< X-Drupal-Cache: HIT
< ETag: "1349936155-1"
< Last-Modified: Thu, 11 Oct 2012 06:15:55 +0000
< Content-Type: application/json
< Cache-Control: public, max-age=0
< Expires: Thu, 11 Oct 2012 06:40:38 GMT
< Date: Thu, 11 Oct 2012 06:40:38 GMT
< Transfer-Encoding: chunked
< X-Cache: TCP_MEM_HIT from a23-3-105-28.deploy.akamaitechnologies.com (AkamaiGHost/6.8.4.3-9847878) (-)
< X-Cache-Key: /L/1483/82472/1m/www.emmys.com/iphone/category.json
< X-True-Cache-Key: /L/www.emmys.com/iphone/category.json
< Connection: keep-alive
< Connection: Transfer-Encoding
Comment #3
marcingy commentedThis makes sense to me.
Comment #4
kylebrowning commentedThanks!
Comment #5.0
(not verified) commentedadd template