Netlify Cache Busting broken with NextJS Middleware?

Netlify Site name: resplendent-frangollo-dfdb69
Netlify Site ID: f5112980-d17a-4d3a-afb4-d41e60d55813

I’m using the latest version of Netlify’s NextJS plugin & a simple middleware that runs in general.

I’m noticing that requests return with a 200 response, when I believe they should return 304 (according to how Netlify handles cache busting?)

Screenshot provided:

Code repo (demonstrated on the caching branch): GitHub - Joroze/next-netlify-starter-nextauth at caching

Branch deployment URL in question: https://deploy-preview-2--resplendent-frangollo-dfdb69.netlify.app/

Sorry for the delay on this one @Joroze.

However, I’m getting a 304 consistently:

Can you share a HAR file?

Hi @hrishikesh,

I’m afraid you’re testing with the wrong link. Please try the URL https://deploy-preview-2--resplendent-frangollo-dfdb69.netlify.app/ which was provided in the OP.

The preview is based off this PR for the demo as I described: Test caching by Joroze · Pull Request #2 · Joroze/next-netlify-starter-nextauth · GitHub

Thank you!

Hey @Joroze,

Sorry about that, you’re right. I tried this on a site without Next.js and it seems to be something with our Edge Function implementation. For any route with any Edge Function enabled (which the Middleware uses), we currently don’t seem to be sending 304 for paths behind Edge Functions. We’ve asked the devs to confirm if this is expected behaviour.

A confirmation from our devs:

It’s a caveat that exists today. If you don’t modify the response, you can do return instead of return ctx.next() which will allow us to issue 304s.

Let us know if it works.