404s get cached and provided as 200
See original GitHub issueHi!
I followed the next.js ssr-caching example, so I’ve got a route like this:
server.get('/product/:handle', (req, res) => { const queryParams = { handle: req.params.handle }; const pagePath = '/product/' + req.params.handle'; return ssrCache({ req, res, pagePath, queryParams }); });
When a non-existent handle gets hit, the server responds with 404 but the second time it’s 200. How can I prevent this?
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
404's in dynamic routes get cached and provided with status ...
Describe the issue Following the ssr-caching example, get requests to dynamic routes that respond with a 404 status code get cached and ......
Read more >404s being cached by service worker [#3015329] | Drupal.org
There should be a 404 for the missing image. Replace the missing file on the server; On the test browsing session, refresh the...
Read more >How To Prevent Soft 404 Errors In Quick Cache - TechLogon
How to stop Quick Cache returning an incorrect 200 header response for a 404 (Page Not Found) error page – known as a...
Read more >How to avoid caching 404 - Cloudflare Community
I don't know why the 404 caches are not expired after 3 minutes like the official document's statement. Maybe because I set the...
Read more >How do I add no-cache headers to all 404 pages served by ...
Before Cloudflare, a re-request to the 404ed file would very quickly become 200 as rsync does its job. However, since Cloudflare caches all...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
done at https://github.com/Kikobeats/cacheable-response/commit/649de67300be5fe61b8562e4cd9f7b3c77a521be ✨
In the current implementation, you can avoid store a value into the cache if you return
undefined
ornull
: https://github.com/Kikobeats/cacheable-response/blob/master/index.js#L85so, if in your code workflow you return one of these values under your 404 error, then it should be enough to don’t store it into the cache.
Can you confirm me that workflow works?