I'm using NextJS on my project. For every page requests it adds 's-maxage=31536000, stale-while-revalidate' cache-control rules in response. How are these 2 rules supposed to work together?
How does HTTP header "cache-control: s-maxage=31536000, stale-while-revalidate" work?
5.8k Views Asked by Dzianis Sudas At
1
There are 1 best solutions below
Related Questions in HTTP
- Handling both JSON and form values in POST request body with unknown values in Golang
- Why can't I use PUT requests?
- nginx set up reverse proxy from subfolder to a port
- Async Web Server RP2040 returning ERR_CONNECTION_REFUSED?
- Getting `FormatException: Missing extension byte (at offset 6)` exception for accessing `response.body` from a server deployed in Vercel
- Retrieving list of values from MYSQL data base based on input value(LARAVEL 10 )(GET HTTP METHOD)
- Unable to add request headers via CHttpFile - C++/MFC
- Why do we call all http services 'Web Api/Web Service'?
- How to correctly read POST REQUEST body on ESP32?
- on linux gitclone issue remote server error showing fatal error with proxy n port
- Elasticsearch - cascading http inputs from Airflow API
- How to clean the html pages opened in a session?
- UTF-8 is not a valid encoding name
- I dont get the Result i expected when i want to get my Telegram Chatbot id
- NextJS 14 SSE with TransformStream() sending messages in a single response
Related Questions in NEXT.JS
- Error **net::ERR_CONNECTION_RESET** error while uploading files to AWS S3 using multipart upload and Pre-Signed URL
- Check list of pages with axios
- Calling functions from Main Component while using tanstack table
- NextJS 14 site working in development but not in vercel
- Route Handler not working Next auth, Next Intl & Next 14
- NextJS Docker build fails: fetch failed ECONNREFUSED
- Need some advice on differentiating between subscriptions using Stripe
- Update Sidebar Height to Cover the Document Height (with React Pro Sidebar)
- How do I send an audio file to OpenAi?
- Next.js not updating state during OnClick after router.push to same page with different ID
- Next js delay before applying Emotion and MUI styles
- Next.js. Server actions in form using formik. Action with arguments didnt work
- Protect Server Actions with Next Auth in Next JS 14
- Next-Auth credentials login troubles debugging
- Hydration failed because the initial UI does not match what was rendered on the server: Next js Tanstack table
Related Questions in CDN
- CDN Detector Extension / Script
- Vite Serving Libraries without CDN
- Use Next.js project as a script tag in html file
- Serve static site on S3 + CloudFlare with Apache retaining the source URL
- Sellapp integration with React
- Is a CDN service worth it for storing images or can I use the MongoDb and my server to serve them?
- Azure CDN and caching control show TCP_MISS
- Next.jS SSG on s3bucket doesn't work on refresh
- I want to cache cloud function data in to cdn. Whatever i tried is caching in browser only
- How to get statistics about uri in azure
- Can't import PrimeVue InputOpt in CDN project
- how to reduce the website image to 2-5kb per for an ecommerce website?
- CDN for asset delivery with auth, locally run and CI support
- Can't render DataTable using Vue and PrimeVue from CDN
- How can I publish a reusable react component into CDN?
Related Questions in CACHE-CONTROL
- Is it possible to force a browser to use the same cache entry for different paths?
- okhttp cache-control no-cache processing strategy
- Why does the browser force revalidation when serving an initial document request?
- Light speed working on private window(incognito) while not working in normal window of a browser
- Application slowness issue in Chrome
- souin cache, revalidating cached objects in the background while serving stale ones
- NGINX : Static resources missing. Server response code 304
- Flutter: How to extend the age of the cached image
- How do I add Cache-Control with no-cache and no-store header in Spring Boot?
- Nextjs cache and cloudflare cache are not synced with getStaticProps revalidation
- object metadata (cache control) being deleted whenever new version uploaded?
- How to Troubleshoot Resource Caching Issues in Chrome?
- How to stop Starlette from setting "Cache-Control: no-cache"?
- Unable to Override Cache Control response headers in ASP.net Web API using OwinMiddleware for signalr/negotiate signalr/start calls
- Expires headers and cach control headers on but page speed test showing cache policy error
Related Questions in S-MAXAGE
- How does HTTP header "cache-control: s-maxage=31536000, stale-while-revalidate" work?
- Does it make sense to set Cache-Control max-age=0 and s-maxage= not zero?
- Symfony2 HttpCache setSharedMaxAge() always 0
- Windows Batch Programming
- Is max age relative to last-modified date or request time?
- Sprockets max-age header on heroku
- jQuery load function ignores Cache-Control max-age
- its not printing proper no.of grid points on the screen?
- How to set the S-MaxAge CacheControl value in an ASP.NET app?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
s-maxageandstale-while-revalidateare part of thecache-controlHTTP header standard that instruct caching of web objects.As your question alludes, they are allowed to be comma separated to achieve your desired caching strategy.
The first value (
s-maxage) is how long the object should be cached in seconds. It also "overridesmax-ageor theExpiresheader, but only for shared caches (e.g., proxies) and is ignored by private caches" - see HTTP expirationThe second value (
stale-while-revalidate), if supported, is how long after thes-maxageexpiration the object can be cached for until it needs to be requested from your site again.Example
cache-controldirectivesHere is how to set caching headers in Next.js.
Here is a related post I made that highlights ISR process in Next.js.