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(vercel, netlify): introduce isr route rule #1124

Merged
merged 2 commits into from
Apr 11, 2023
Merged

feat(vercel, netlify): introduce isr route rule #1124

merged 2 commits into from
Apr 11, 2023

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Apr 11, 2023

πŸ”— Linked issue

Resolves #946

❓ 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

We had been experimenting vercel ISR and netlify Builders feature via an implicit cache route rule.

Introducing a new isr flag, unblocks to combine nitro native cache (SWR) with platform native rules and giving the flexibility to use the most effective caching mechanism. (Currently, on these platforms nitro cache/storage cannot be used)

Note: This is a semi-breaking change for this platforms however switching swr to built-in behavior still preserves in memory cache so caching keeps working only can be changed to either isr or permanent by mounting /storage for production.

This PR also drops (almost unused) static cache rule.

πŸ“ Checklist

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

@pi0 pi0 requested a review from danielroe April 11, 2023 12:15
@codecov
Copy link

codecov bot commented Apr 11, 2023

Codecov Report

Merging #1124 (d3729e3) into main (ea5ea88) will decrease coverage by 0.04%.
The diff coverage is 94.11%.

@@            Coverage Diff             @@
##             main    #1124      +/-   ##
==========================================
- Coverage   67.77%   67.73%   -0.04%     
==========================================
  Files          63       63              
  Lines        6370     6345      -25     
  Branches      713      704       -9     
==========================================
- Hits         4317     4298      -19     
+ Misses       2039     2033       -6     
  Partials       14       14              
Impacted Files Coverage Ξ”
src/options.ts 87.36% <ΓΈ> (-0.17%) ⬇️
src/presets/vercel.ts 77.72% <92.30%> (+0.93%) ⬆️
src/presets/netlify.ts 59.62% <100.00%> (-0.98%) ⬇️
src/types/nitro.ts 100.00% <100.00%> (ΓΈ)

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

Copy link
Collaborator

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is πŸ‘Œ A good implementation and addresses my worry about being too provider-specific.

But maybe worth (if not using vercel/netlify) setting native nitro cache options if isr is enabled?

@pi0
Copy link
Member Author

pi0 commented Apr 11, 2023

But maybe worth (if not using vercel/netlify) setting native nitro cache options if isr is enabled?

It would be indeed a nice idea if we could emulate isr functionality for other production platforms. Let's iterate over this. I think one main difference that swr lacks is to invalidate/segment cache based on deployment id.

Feel free to make PR for both ideas btw.

@pi0 pi0 merged commit 30c2c14 into main Apr 11, 2023
@pi0 pi0 deleted the feat/isr-rule branch April 11, 2023 14:11
@pi0 pi0 mentioned this pull request Apr 28, 2023
@Hebilicious
Copy link
Contributor

It should be possible to implement ISR for the cloudflare providers by leveraging the Cloudflare cache API like here. The isr value can be forwarded to the cache-control header as well.
This would be very neat πŸ‘Œ

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.

Dedicated cache rules for vercel ISR and netlify Builders
3 participants