I’m using Netlify server caching with nextjs v14. I’m setting caching headers in getServerSideProps function based on custom logic. I want to implement caching logic such that.
- Only for certain query parameters like filter or sort, caching should be skipped and data should be fetched from server and
- Serve the same cached response for any other query params.
I had tried setting Netlify-Vary: query in next.config.js which works fine and getServerSideProps function runs again whenever there is any query params. This solve the first issue because I have added condition to set no-store caching header when there are filter or sort params.
But because of the Netlify-Vary header being set, all other query params are getting cached uniquely which is not correct. I want same cache as the base url to be served to url containing any parameters except filter or sort params.
Could anyone please let me know if there is any way I can get this working? Or if there is any other workaround