sitemap.xml cached somehow? #56708
Replies: 7 comments 3 replies
-
Same problem, no help. I am using nextjs and vercel for deployment. |
Beta Was this translation helpful? Give feedback.
-
Maybe a result of #60998 ? |
Beta Was this translation helpful? Give feedback.
-
It looks like it only updates on deploy without |
Beta Was this translation helpful? Give feedback.
-
Just use https://nextjs.org/docs/app/api-reference/functions/unstable_noStore For example: import { myFetch } from '@/data';
import { unstable_noStore as noStore } from 'next/cache';
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
noStore();
const data = await myFetch();
return ...
} That worked fine for me. Though keep in mind that there is a limit of 50K links in a sitemap for Google. You will need to use https://nextjs.org/docs/app/api-reference/functions/generate-sitemaps if you have more than that. |
Beta Was this translation helpful? Give feedback.
-
These solutions fix the issue, but not the underlying problem. Next.js framework should set caching headers correctly. It should not be necessary to fix it individually. |
Beta Was this translation helpful? Give feedback.
-
In my case our sitemaps are generated by the CMS and stored in a S3, but for some reason they got cached as well since they pass through the frontend domain and Idk how to prevent this to happen. Please help! 😢 |
Beta Was this translation helpful? Give feedback.
-
According to the sitemap documentation:
The answer to the larger question is that the sitemap route is cached (indefinitely) by next's Full Route Cache. The Full Route Cache is cleared on new deployments. However, it should be noted that the Data Cache persists across deployments. Therefore, (as I understand it) it is theoretically possible that a Full Route Cache is regenerated after a deployment using data in the Data Cache. In my use case, I didn't want to disable the Full Route Cache (or the Data Cache, for that matter); I want some caching on the sitemap, just not indefinite caching, since I'm pulling content dynamically from a CMS. I opted to go with using the import { MetadataRoute } from 'next';
export const revalidate = 300;
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
// ...
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I'm trying to update my sitemap.xml, but it appears to be cached somehow as changes aren't reflected on my live site when updating with a new version.
I use an SEO tool generated sitemap.xml file, which is placed in the app directory. Pushed to Github and then the site is rebuilt on my Caprover server.
I've tested it in various browsers with the same result. Where could this cache issue be?
Additional information
Beta Was this translation helpful? Give feedback.
All reactions