ISR Pages not using browser cache, (max-age header not there) and reduce CDN requests. #38056
shmdhussain
started this conversation in
Ideas
Replies: 1 comment
-
@shmdhussain Did you find a solution on this to set a "max-age" value based on "s-maxage" ? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the feature you'd like to request
right now pages using the getStaticProps have the cache header as
Cache-Control: s-maxage=60, stale-while-revalidate
note: I have revalidate: 60 sec in the object returned from getStaticProps
I understand this means we use the stale response in the browser if available
for the page, while checking for updates.
My setup is
Browser ---> CDN ---> Nextjs Origin server
In CDN:
When checking updates in the background, the request will go to CDN and CDN will check if it has the page in the cache, then it will serve that otherwise, it will send an expired page response while it refreshes the page in the background with nextjs origin server.
here I see an important point missing is browser cache is missed as we do not have the
max-age
header in the nextjs server response,Describe the solution you'd like
If the nextjs could provide cache control header as
Cache-Control: max-age=60, s-maxage=60, stale-while-revalidate
--> this can have at-most have 120 sec (cnd 60 _ browser 60) cached data.then browser cache will be involved for 60 sec since page is fetched and it prevents the request go to CDN for each request in the browser, so that we could avoid CDN RTT and use the browser cache efficiently and serve the page quickly.
Describe alternatives you've considered
Either we can have some option to include the max-age rather than having s-max-age as default so that we could use the browser cache and avoid hitting the CDN.
Beta Was this translation helpful? Give feedback.
All reactions