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

feat(cloudflare): cacheControl support for public assets with with maxAge #922

Merged
merged 3 commits into from
Feb 8, 2023

Conversation

oleghalin
Copy link
Contributor

@oleghalin oleghalin commented Feb 6, 2023

πŸ”— Linked issue

#919

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

For now if you serve website to Cloudflare Workers you exceed free (and even paid) limits very fast because each request serves assets directly from worker and never cache in browser.

I think that it will be great to get maxAge from publicAssetURLOptions, but i didn't touch rollup virtual code to make it work.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@oleghalin
Copy link
Contributor Author

Sorry, @pi0, is there any chance to review this ASAP to make it available for production projects, without this changes Workers apps spend a lot of CF Limits, thanks.

PS. maybe its possible to define custom preset directly in nuxt application? Your feedback will help me very much

@codecov
Copy link

codecov bot commented Feb 7, 2023

Codecov Report

Merging #922 (409c337) into main (41884ba) will increase coverage by 0.03%.
The diff coverage is n/a.

❗ Current head 409c337 differs from pull request most recent head 5867851. Consider uploading reports for the commit 5867851 to get more accurate results

@@            Coverage Diff             @@
##             main     #922      +/-   ##
==========================================
+ Coverage   67.48%   67.51%   +0.03%     
==========================================
  Files          59       59              
  Lines        5911     5911              
  Branches      660      661       +1     
==========================================
+ Hits         3989     3991       +2     
+ Misses       1913     1911       -2     
  Partials        9        9              
Impacted Files Coverage Ξ”
src/rollup/plugins/public-assets.ts 93.38% <0.00%> (+1.65%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@pi0
Copy link
Member

pi0 commented Feb 8, 2023

Thanks for PR dear @oleghalin. I have pushed some new additions in top of it. We needed to map maxAge from public assets configuration to actual meta (otherwise all assets would be cached for a long time even unhashed ones)

@pi0 pi0 changed the title fix(nitro): Cloudflare Workers KV Cache Control ttl for public assets feat(cloudflare): cacheControl support for public assets with with maxAge Feb 8, 2023
@pi0 pi0 merged commit 247f312 into nitrojs:main Feb 8, 2023
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

Successfully merging this pull request may close these issues.

2 participants