pantheon-systems / WordPress

WordPress upstream for the Pantheon website platform. Includes a platform integration plugins and a pre-configured wp-config.php.
Other
177 stars 225 forks source link

Caching is applied to both browser and CDN #204

Open jakub300 opened 5 years ago

jakub300 commented 5 years ago

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.

davidstrauss commented 5 years ago

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 commented 5 years ago

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 commented 1 year ago

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.