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

Why is enableCacheInterception dangerous? #738

Open
vicb opened this issue Feb 12, 2025 · 4 comments
Open

Why is enableCacheInterception dangerous? #738

vicb opened this issue Feb 12, 2025 · 4 comments

Comments

@vicb
Copy link
Contributor

vicb commented Feb 12, 2025

ref:

// open-next.config.ts

const config = {
  // ...
  dangerous: {
    enableCacheInterception: true,
  },
};

I was wondering why enableCacheInterception is on dangerous and why it is disabled by default?

Would it make sense to change that?

/cc @conico974

@conico974
Copy link
Contributor

Well the main reason is that it is not as well tested and that it bypass NextServer totally in some cases. It could behave differently than next start.
For example at the moment a route revalidated with revalidateTag would require 2 Incremental Cache get as well as checking the cache tags twice (because it fallback to normal NextServer if not found )
It has 3 main benefits :

  • It's usually a lot faster (No need to load the js for an SSG route)
  • It allows ISR/SSG route to be served directly from the routing layer (especially interesting with an external middleware)
  • That's what's necessary to make PPR work in the same way as in vercel

I don't think that it is something that we want to enable by default, but with more thorough testing we could move it outside of dangerous

@vicb
Copy link
Contributor Author

vicb commented Feb 12, 2025

Thanks for the clarification @conico974

Would it make sense to add the details to https://opennext.js.org/aws/inner_workings/cache_interception ?

(and for the context I was looking at what we should recommend to our users)

@conico974
Copy link
Contributor

Yeah we can add some more info in the docs.

As for if it should be recommended on cloudflare, this is probably the place where it is the least interesting.
The only benefits as of now in cloudflare would be that it may be a bit faster in some cases (but that's mostly true for cold start)

@vicb
Copy link
Contributor Author

vicb commented Feb 12, 2025

The only benefits as of now in cloudflare would be that it may be a bit faster in some cases

I think it could really help when the external middleware is actually external (i.e. in a separate worker)

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

2 participants