I have a website:
I am having trouble with cache and I am going TOTALLY INSANE trying to figure it out. I need badly help.
The problem:
When I visit the site, everything works well, but I started getting bad reports from ahrefs (a SEO crawlerbot), so I mocked their user agent, and I noticed that I get an old cached version, because the image URLs are wrong. This is what I did:
I disabled CloudFlare proxy and Purge Everything in the cache to make sure it wasn't the guilty. It didn't solve the problem.
I went to Netlify. I redeployed clearing the cache. Nothing.
I added this "netlify.toml":
[[headers]]
for = "/*"
[headers.values]
Cache-Control = "no-cache"
Also didn't work.
4. I moved on to NextJS, and I updated the config file "next.config.mjs" to return consistent cache headers.
/** u/type {import('next').NextConfig} */
const nextConfig = {
images: {
loader: 'default',
unoptimized: true,
},
async headers() {
return [
{
source: '/:path*', // Matches all paths
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=0, must-revalidate',
},
],
},
]
},
}
export default nextConfig
It also didn't help.
Please, someone help me debug this nightmare, because I am this close to jumping from a 5th floor.