NuxtN
Nuxt17mo ago
3 replies
.fondazione

Server API proxy caching approach

Hi all, I have a question regarding an approach to server api caching.
I am using Sanity IO as a backend and I'd like to cache my server routes which is no problem.
In my case right I have a filter function where a type (e.g. "posts") can be filtered with multiple tags, and I was wondering what the best approach is, because in my test queried cached routes did not work.

Since the amount of filters/tags is infinite, I was thinking of a post request and not a get request. But how would I cache this route since the post req is always different/can change?

One option I was thinking of is to have a cached route with all posts which then is fetched and filtered by the filtered route? Is that the correct approach? Or should I cache Route Parameters?

server/
└── api/
    ├── posts.get.ts  // cached
    └── filtered.get.ts // not cached


Whats the best way to approach this? Also the amount of posts is quite large, I am guessing around 1.000 entries

Thank you!
Was this page helpful?