WordPress icon indicating copy to clipboard operation
WordPress copied to clipboard

Caching is applied to both browser and CDN

Open jakub300 opened this issue 5 years ago • 3 comments

https://github.com/pantheon-systems/WordPress/blob/215de666b100fc08ce3ceb26b44242c19548d004/wp-content/mu-plugins/pantheon/pantheon-page-cache.php#L278 https://github.com/pantheon-systems/WordPress/blob/215de666b100fc08ce3ceb26b44242c19548d004/wp-content/mu-plugins/pantheon/pantheon-page-cache.php#L289

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.

jakub300 avatar Jun 03 '19 13:06 jakub300

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.

davidstrauss avatar Jun 03 '19 15:06 davidstrauss

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.

jakub300 avatar Jun 05 '19 22:06 jakub300