Open simonhrogers opened 4 months ago
Hi, thanks for the details.
This sounds like the default behavior which is to cache the sitemap for 10 minutes (see Sitemap Caching).
Since the sitemap is hit quite often by robots we can reduce the cost of running our site by caching this data. You can usually see the cache status by inspecting the response headers, the URL you provided looks like caching is off though
If this is caching longer than 10 minutes though it sounds like a bug.
Hey Harlan!
Thanks so much for your work on this and sorry for missing that detail – I had read the docs and understood that there was a cache by default.
I checked with a variety of times including unset, 10 minutes set explicitly and then 1 second / 10 seconds to be sure it wasn’t working. In the case of the 10 minute wait I did wait 20 minutes incase I was misunderstanding when the cache was being reset.
Would it be helpful if I set a cache time again and inspected the response headers?
I did also visit the cached Sitemap in private session / different browser incase there might be any issues with my browser config.
S
The only catch may be that the cache is SWR so it will serve old sitemaps after 10 minutes and refresh in the background. Otherwise, it should be resetting.
Any reproduction would be useful to debug further.
So if this is still an issue the only thing I think I can do on my end is set a cache time to 0 seconds by default for Netlify and add a warning if users set a cache time.
Let me know your thoughts, it's a bit strange no one else has reported this though.
Hello!
So this is a fairly simple one to describe, I’m not sure if I’m missing something?
My first instinct was to blame Netlify, but I realised if it is working perfectly with
cacheMaxAgeSeconds: 0
then it must be something more complicated at play."@nuxtjs/sitemap": "^5.2.0",
"nuxt": "3.12.1",
Here is my nuxt.config.ts setup:
and here is the referenced
api/sitemap
function – this works perfectly as an endpoint; it updates instantly even on Netlify.Here is the hosted sitemap:
https://staging--tinworks.netlify.app/sitemap.xml
Thank you for any guidance :-)