revalidate not works in deployed project
Unanswered
Brown bear posted this in #help-forum
Brown bearOP
I use sanity and next app
I put revalidate for the build once a day but the data not change.
I most to deploy in my self to see changes
I put revalidate for the build once a day but the data not change.
I most to deploy in my self to see changes
9 Replies
You should try specifying cache revalidation inside the client call.
From Sanity's official plugin for Next: https://www.sanity.io/plugins/next-sanity#time-based-revalidation
const data = await client.fetch(query, {}, {
next: {
revalidate: 86400,
},
});From Sanity's official plugin for Next: https://www.sanity.io/plugins/next-sanity#time-based-revalidation
Brown bearOP
@not-milo.tsx is see now that even after deploy the ssg content not change the cache is to strong
If you want to avoid caching on deployments you can manually disable it when triggering the redeploy, or you can append
?buildCache=false at the end of the deployment webhook.Brown bearOP
name: Production Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
push:
branches:
- main
jobs:
Deploy-Production:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v3
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
where ?
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
push:
branches:
- main
jobs:
Deploy-Production:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v3
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
where ?
Currently there's no way of doing it from automated ci/cd pipelines (see this discussion: https://github.com/vercel/vercel/discussions/8057#discussioncomment-3057196). You have to use a deploy webhook or do it manually from the dashboard.
Brown bearOP
You want to tell me that if I want to use ssg I need to rebuild in myself every day?
how I rebuild manually?
@Brown bear You want to tell me that if I want to use ssg I need to rebuild in myself every day?
No, I'm trying to tell you that there's a better way. You can set up a build hook on Sanity that calls the Vercel api and rebuilds the website when an editor publishes new content. It's all automated, you don't have to do anything.
All you have to do to set it up is go to your Sanity dashboard and add a new webhook in the api section (https://www.sanity.io/docs/webhooks). And then you have to create a deploy hook from your Vercel dashboard, you'll find instructions here: https://vercel.com/docs/deployments/deploy-hooks.
All you have to do to set it up is go to your Sanity dashboard and add a new webhook in the api section (https://www.sanity.io/docs/webhooks). And then you have to create a deploy hook from your Vercel dashboard, you'll find instructions here: https://vercel.com/docs/deployments/deploy-hooks.
Brown bearOP
Ok nice thank you!!!