-
Notifications
You must be signed in to change notification settings - Fork 122
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
@W-13718763: use s-maxage to only cache shared cache #1564
Conversation
This PR addresses #1319 I deployed these changes onto a test environment: https://scaffold-pwa-test-env-2.mobify-storefront.com/ I can see the s-maxage appear on the home page. But on both the PDP and PLP, I see both a maxage and s-maxage s-maxage overrides maxage where it can but I think we're trying to remove maxage entirely from these pages? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a quick search of our default Cache Control directives and noticed that a few resources are still using "max-age".
res.set('Cache-Control', `max-age=31536000`) pwa-kit/packages/pwa-kit-create-app/assets/bootstrap/js/overrides/app/pages/home/index.jsx.hbs
Line 54 in a5f9b14
res.set('Cache-Control', `max-age=${MAX_CACHE_AGE}`) res.set('Cache-Control', `max-age=31536000`)
Should we consider updating the Cache Control headers directive to use "s-maxage" instead of "max-age"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, remember to add a new entry to the Changelog.
Description
The
max-age
directive implies that a page can be cached both by the browser and the shared CDN cache.When a new bundle is deployed to an environment, the shared CDN cache is cleared, but stale copies of the site might still exist in a shopper's browser.
We could avoid this situation by moving to s-maxage, which only caches in shared caches:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#s-maxage
Types of Changes
Changes
How to Test-Drive This PR
Checklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization