tractorcow / silverstripe-dynamiccache

Simple on the fly caching of dynamic content for Silverstripe
39 stars 27 forks source link

Pages served from dynamiccache have Cache-Control: no-cache header #26

Closed sekjal closed 8 years ago

sekjal commented 8 years ago

By starting the session first thing in DynamicCache::run(), the default session_cache_limiter of 'nocache' is set, which results in the headers

Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache

being set on items served from dynamiccache. These do not seem to be affected by .htaccess rules using mod_header.c.

While this does have the advantage of handing over "freshness" checking to the server (so content updates are distributed immediately), it prevents browser caching and proxying, which may be appropriate for a particular seldom-changing page. Not usually a huge issue with LAN or solid wireless connections, but network overhead can be a significant performance issue on mobile.

Perhaps make this a configurable variable, so administrators can tune the behavior to their application?

tractorcow commented 8 years ago

Yeah this should be set to a proper caching policy. ;D PRs welcome.

sekjal commented 8 years ago

Experimenting with the existing configuration options, I think an additional configuration parameter may be unnecessary. By modifying the cacheHeaders config to:

cacheHeaders: '/^(X\-)|(Cache\-Control)|(Etag)|(Expires)|(Last\-Modified)/i'

I am able to specify my configuration preferences in .htaccess.

Should this be the new default for this config option, or just documented?

tractorcow commented 8 years ago

Probably a new default setting. ;)