I'm running a job aggregator and I wish to avoid cache on my post feed, since its showing outdated results to my users. We're running on Next.JS.
I've searched through their docs, but didn't find a way about how to do it...
Does someone have an idea?
I assume its on next.config.js, but I don't know exactly how.
Here's how... When you're in Google Chrome, click on View, then select Developer, then Developer Tools. Alternatively, you can right click on a page in Chrome, then click Inspect. Click on the Network tab, then check the box to Disable cache.
Next. js will generate etags for every page by default. You may want to disable etag generation for HTML pages depending on your cache strategy.
Caching. Caching improves response times and reduces the number of requests to external services. Next. js automatically adds caching headers to immutable assets served from /_next/static including JavaScript, CSS, static images, and other media.
This seems work if server-side rendering
Page.getInitialProps = async ({ store, res }) => {
if (res) {
// res available only at server
// no-store disable bfCache for any browser. So your HTML will not be cached
res.setHeader('Cache-Control', 'no-store');
}
await store.dispatch(action());
return {};
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With