Skip to content

Sitemap cache usage with _sitemap-urls.ts? #194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
notflip opened this issue Dec 29, 2023 · 10 comments
Closed

Sitemap cache usage with _sitemap-urls.ts? #194

notflip opened this issue Dec 29, 2023 · 10 comments

Comments

@notflip
Copy link

notflip commented Dec 29, 2023

Details

I'm using _sitemap-urls.ts to fetch dynamically created pages (using Directus CMS), now I see that the client deleted a page, but the sitemap is not updating, even though I have set the following

  modules: [
    [
      "nuxt-simple-sitemap",
      {
        excludeAppSources: ["nuxt:pages"],
        cacheMaxAgeSeconds: 3600,
      },
    ],
}

How do I make sure that updates in the CMS are also reflected in the sitemap?
Thanks

@harlan-zw
Copy link
Collaborator

harlan-zw commented Dec 29, 2023

Hi, the sitemap is cached by default for 10 minutes using a SWR caching strategy. You can learn more here: https://nuxtseo.com/sitemap/guides/cache

This may be of interest:

If you want to disable caching, set the cacheMaxAgeSeconds to 0.

If you're saying that it's not clearing the cache after 10 minutes, and you're not prerendering it, then it may be a bug I need to look into, can you confirm.

@notflip
Copy link
Author

notflip commented Dec 31, 2023

@harlan-zw Thanks for getting back, it is not in fact clearing the cache right now, I've made some changes 2 days ago, even did a redeploy on Netlify and I'm still seeing old data. Is there a method to forcefully clear the cache?

(I checked the server endpoint, the cache there is updated, so the issue is indeed in the frontend/sitemap).

@harlan-zw
Copy link
Collaborator

Silly question, but are you sure you're not prerendering the sitemap? Is it possible to share a live URL?

Also please provide the version you're using

@notflip
Copy link
Author

notflip commented Jan 2, 2024

@harlan-zw How do I know for sure if I'm not pre-rendering, I'm hosting the project on Netlify, with the ssr: true flag in nuxt.config.ts, the sitemap.xml file does not exist in my source code. The build command on Netlify is nuxt build.

@harlan-zw
Copy link
Collaborator

If you inspect the HTTP response headers it should give you details on the caching. If you provide the live URL i can help with this (feel free to DM me on discord if you want to keep it private).

To try and debug you can also try disabling the caching by providing cacheMaxAgeSeconds: 0

@notflip
Copy link
Author

notflip commented Jan 3, 2024

@harlan-zw Thanks for helping out, this is the live url: https://dedirekteurswoning.be/sitemap.xml The cacheMaxAgeSeconds is now set to 1 hour.

@harlan-zw
Copy link
Collaborator

Definitely something broken here, current Age is 178400 🤔 Will try investigate further when I have a chance

@notflip
Copy link
Author

notflip commented Jan 8, 2024

@harlan-zw Is there a way to forcefully invalidate the cache now? Thanks!

@PabloGBarcelo
Copy link
Contributor

PabloGBarcelo commented Jan 14, 2024

Hey @harlan-zw,

I took a look at this, and it seems to be a challenge with Netlify.

Could the problem be related to this topic? Go to Netlify Forum Post

Changing the header breaks the cache invalidation. Cache invalidation only works with the default headers. If you modify the cache-control headers, the new header will modify the caching for any and all URLs that use the modified header.

My website vs. notflip's website

The request headers are defining the max-age as 0, but the notflip's website response is indicating 31536000 (Strict-Transport-Security = 1 year). So maybe we should fix the way the cache control is being injected
Image

@harlan-zw
Copy link
Collaborator

Going to close this in favour of #288 (duplicate).

@harlan-zw harlan-zw closed this as not planned Won't fix, can't repro, duplicate, stale Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants