Skip to content
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

Invalidate cache in production env when serving files from GitHub source #2260

Open
ManasMadrecha opened this issue Aug 28, 2023 · 9 comments

Comments

@ManasMadrecha
Copy link

ManasMadrecha commented Aug 28, 2023

Environment

.

Reproduction

I'm using a private GitHub repo as my source for Content module.

The app is a server app, i.e., Nitro app deployed on on Firebase Cloud Functions.

I have created a file server/api/abc.ts wherein it fetches from serverQueryContent. It serves the docs so fetched. It also has a simple Firebase authentication check, i.e., if the request header has a Authorization Bearer token, then serve the docs with x query, else serve with y query.

In frontend vue page, I am using this api to fetch, i.e.,

## /pages/index.vue

const {data} = await useFetch('api/abc')

Describe the bug

When I update the contents on my GitHub repo, the deployed production app should serve the updated version, i.e., it should automatically fetch the newer version of GitHub repo.

However, even on refreshing the page, it serves from the cached version of the repo files as on the time of running npm run build. I waited for 10 minutes, as it is the default TTL in unstorage module, but to no avail.

Note: the authentication guard is working on the server api, i.e., the page shows x query if someone is logged in and as soon as the person logs out, y query is automatically shown. So the api is updating itself. But the api is not fetching the newer GitHub repo, but I think it is fetching from the cache.<integritynumber].json file even in production env.

Additional context

No response

Logs

No response

@farnabaz
Copy link
Member

In production, the Module does not revalidate its cache, and it always uses built time cache.
This feature might introduce in next release under an experimental flag, and currently there is no standard solution for it.

@ManasMadrecha
Copy link
Author

ManasMadrecha commented Sep 1, 2023

@farnabaz @shareable-vision

Will solving #2260 solve this issue?

Edit: Will solving #2211 solve this issue?

@nobkd
Copy link
Contributor

nobkd commented Sep 1, 2023

Did you mean #2211 with #2212?

@ManasMadrecha
Copy link
Author

@nobkd Yes. 😁 Thanks for pointing these.

@lysz210
Copy link

lysz210 commented Jan 25, 2024

I'm trying to implement a dynamodb driver for nuxt content. I make it work in local but the build application never call dynamo.
I tryed implementing nitro storage and used it without nuxt/content and workes.
After checking code I found this:

if (isProduction && cached) {

  const cached: any = await cacheParsedStorage.getItem(id)
  if (isProduction && cached) {
    return cached.parsed
  }

  const meta = await sourceStorage.getMeta(id)
  const mtime = meta.mtime

For what I can tell if isProduction it always returns the cached content and never try to get meta for eventual newest.
For me it should be enough to add a parameter to H3Event and change to if (event.dynamicContent && isProduction && cached) {. I'll try to fork and implement it.

@wesamjabali
Copy link

I'm also running into this problem. The buildtime cache makes nuxt content unusable with non-fs drivers.

@feritarou
Copy link

@lysz210 Did you manage to get a fork working? I'd be very interested to hear about your experience given that neither this issue nor the related #2212 seem to be progressing recently.

Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Nov 27, 2024
@ManasMadrecha
Copy link
Author

Commenting to remove stale tag

@github-actions github-actions bot removed the Stale label Dec 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

6 participants