-
Notifications
You must be signed in to change notification settings - Fork 991
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
Update Cache Control #6874
Update Cache Control #6874
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Deployment failed with the following error:
Learn More: https://vercel.link/invalid-route-source-pattern |
Deployment failed with the following error:
Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
Deployment failed with the following error:
Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
Deployment failed with the following error:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! verified all images loaded from the memory cache, and did not when 'Disable cache' was disabled woo. Hoping this helps with the overages
What are you changing in this pull request and why?
This is an effort to improve caching of our docs site to reduce Vercel overages. The strategy here is to cache all images to the browser for up to 31 days. This should reduce network requests on images, thus reducing our Fast Data Transfer and Edge Requests overages.
One thing i'm not 100% clear on is whether retrieving an item from the CDN cache counts towards our Fast Data Transfer. I believe it does, as I see the Request Header
x-vercel-cache: HIT
consistently across network requests and we are still going over our limit.CDN requests count towards Edge Requests. And assets loaded from the CDN (such as images), count towards Edge Requests (docs here). So this should be able to help with both overages potentially.
![image](https://private-user-images.githubusercontent.com/13647110/410523667-9bd05dfb-887e-458c-8411-38b90cc2d79e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNzgyMTYsIm5iZiI6MTczOTM3NzkxNiwicGF0aCI6Ii8xMzY0NzExMC80MTA1MjM2NjctOWJkMDVkZmItODg3ZS00NThjLTg0MTEtMzhiOTBjYzJkNzllLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDE2MzE1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNlNGUwYWRjM2RjZTNjOTg4YTdmMDlkMjZiZGYyNjk4ODNhMDcyNjQ3MzY3OTU4Nzc3NDNiMTc5MGJjYzUyYjkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.aXNSgLeD-C_QOVMCdWfW8NFHDCzbA8BGYF7D4tPaA1c)
Cache settings
Images: Cache images in browser for 31 days, on CDN for 7 days.
Everything else: Cache everything else on CDN for 1 day, & don't cache on the browser.
Preview
This page has a good amount of images to verify the cache:
https://docs-getdbt-com-git-update-cache-headers-dbt-labs.vercel.app/reference/node-selection/test-selection-examples
In the network tab, reload the page and verify images are now being cached by the browser. You may have to select the
![image](https://private-user-images.githubusercontent.com/13647110/410515133-27683e34-d330-424e-b08e-ae4746387d81.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNzgyMTYsIm5iZiI6MTczOTM3NzkxNiwicGF0aCI6Ii8xMzY0NzExMC80MTA1MTUxMzMtMjc2ODNlMzQtZDMzMC00MjRlLWIwOGUtYWU0NzQ2Mzg3ZDgxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDE2MzE1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFiODQ5YzliMWYzOWVjZjNkOTAzY2U2MGJkNmUyNTM4ZDMzOTY5MmZhMTQ1NzhiM2JkZjJiMzZlNTc1MDk1MzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.oCe5za88KFU44lsjgppqQpYxjBOnRY-_aGeVXZFBeRc)
Disable cache
option within the network tab.Select an image in the network tab, and verify the
Cache-Control
matches what is set in thevercel.json
within this PR.Verify that other file types such as css, js, etc. use the fallback
Cache-Control
ofmax-age=0, s-maxage=86400 stale-while-revalidate
, which caches the item in Vercel's CDN for 1 day.Notes
I will give the docs team a heads up when replacing images, the new image should have a unique name. If we ever need to bust the browser image cache, we can use the existing image-cache-wrapper. We can update the
CACHE_VERSION
to 3.Note on the CDN cache - New Vercel deployments invalidate the CDN cache (see docs here), so it should be safe to cache everything on the CDN without seeing stale content after updates.
🚀 Deployment available! Here are the direct links to the updated files:
TODO