public/images) which by default gets no cache (public, max-age=0, must-revalidate) and so the optimizer serves them with this header as well._headers file in the root of the project but they don't seem to get included in the final build../.vercel/output/static/_headers after the build by adding this to the end of the generated file:4/17/24, 9:12 PM
4/17/24, 9:31 PM
revalidateTag to clear fetch cache and it works ~80% of the time. I've narrowed the issue down to locations. If you access the web page from a distant location (via VPN) the data is "stuck" on an older version. Almost like the data cache isn't clearing and propagating, so when accessing the page remotely it loads instantly (seemingly via cache) since it doesn't know about fresh data.revalidateTag) and after a stale request has been made. Then, after a fetch, it should cache again. This is standard nextjs functionality and has worked me on Vercel.revalidateTag for years on Vercel. It works great and is a modular way to manage data cache.revalidateTag with relevant tags. I then view the page on my browser and refresh it shows the latest post titles on the home page and correct post titles. However, browsers in other locations show old data (even after refresh). And the old data is staying for days. My fetch revalidate is only set to 300 seconds (5mins)..next cache. Surely that's not right? Even if it were right, you'd need a way to invalidate cache across all of it, on demand. But I can't find that anywhere.wrangler.toml : https://github.com/cloudflare/next-on-pages/blob/main/internal-packages/next-dev/README.mdnpm create cloudflare@latest select "Website or web app" and "Next". Uncomment the KV section in wrangler.toml and app/api/hello/route.ts. start dev server npm run dev and visit http://localhost:3000/api/hello . If that works for you, then check that you have all the needed packages and correct versions (wrangler & @cloudflare/next-on-pages) etc.getRequestContext() on the edge and I can only set export const runtime = "edge"; within an api route, right? (Nextjs 14)use server within the files in your D1 folder? {
async headers() {
return [
{
source: '/cdn-cgi/image/(.*)', // does not work
headers: [
{
key: 'cache-control',
value: 'public, max-age=14400',
},
],
},
{
source: '/images/(.*)', // does not work
headers: [
{
key: 'cache-control',
value: 'public, max-age=14400',
},
],
},
];
},
images: {
minimumCacheTTL: 3600, // this does nothing
loader: 'custom',
loaderFile: './imageLoader.js',
},
}$ next dev --turbo
/Users/user/app/node_modules/wrangler/wrangler-dist/cli.js:29573
throw a;
^
TypeError: fetch failed
at fetch (/Users/user/app/node_modules/wrangler/wrangler-dist/cli.js:17033:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async getRegisteredWorkers (/Users/user/app/node_modules/wrangler/wrangler-dist/cli.js:127790:22)
at async getBoundRegisteredWorkers (/Users/user/app/node_modules/wrangler/wrangler-dist/cli.js:127810:29)
at async getMiniflareOptionsFromConfig (/Users/user/app/node_modules/wrangler/wrangler-dist/cli.js:173117:29)
at async getPlatformProxy (/Users/user/app/node_modules/wrangler/wrangler-dist/cli.js:173089:28)
at async setupDevPlatform (/Users/user/app/node_modules/@cloudflare/next-on-pages/dist/next-dev/index.cjs:183:23)
at async file:///Users/user/app/apps/web/next.config.mjs:4:3 {