Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching is applied to both browser and CDN #204

Open
jakub300 opened this issue Jun 3, 2019 · 3 comments
Open

Caching is applied to both browser and CDN #204

jakub300 opened this issue Jun 3, 2019 · 3 comments

Comments

@jakub300
Copy link

jakub300 commented Jun 3, 2019

header( 'cache-control: public, max-age=' . $ttl );

$server->send_header( 'Cache-Control', 'public, max-age=' . $ttl );

Pantheon plugin is currently using max-age directive for setting cache duration. This is problematic when configuring long TTL, for example in combination with Pantheon Advanced Page Cache plugin.

With current implementation when long TTL is used the pages will be cached for given time in both CDN and user's browser. When content changes page is purged from CDN but user that visited it recently will still see version from their cache until TTL expires (which may be several days) or he hard reloads.

I think caching should be limited to CDN where it can be purged properly so s-maxage directive or Surrogate-Control header should be used.

@davidstrauss
Copy link
Member

We've discussed this a bit internally before, and I agree. Would you be open to submitting a pull request? Clearly, pages should have some user agent cache lifetime still, but the bulk of the time should be CDN-only.

I generally prefer Surrogate-Control over s-maxage for this situation. That's for two reasons. First, Surrogate-Control providers richer and more isolated CDN vs. user agent control. Second, some Pantheon sites stack their CDN (use their own on top of the platform's own), and s-maxage would extend the long expiration into those CDNs, which are beyond our invalidation control.

@jakub300
Copy link
Author

jakub300 commented Jun 5, 2019

Thanks for the response, I like your reasoning for Surrogate-Control. I may prepare PR at some point if this is not solved, but right now I'm quite busy.

@cjyabraham
Copy link

Any updates on this issue? We have been talking about this independently and would love to see this added to the plugin rather than having to custom-patch our own site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants