strapi-community / strapi-plugin-rest-cache

Speed-up HTTP requests with LRU cache.
https://strapi-community.github.io/strapi-plugin-rest-cache/
MIT License
129 stars 29 forks source link

Any way to cache only plural and not singular endpoints? #50

Open davidkcyip opened 1 year ago

davidkcyip commented 1 year ago

Hi, as the title says, would like to only cache plural endpoints like /articles and not /articles/1

alex-whatagraph commented 1 year ago

+1. any idea if this is possible @stafyniaksacha ?

stafyniaksacha commented 1 year ago

You will have to disable default routes (injectDefaultRoutes: false) and defines yours https://strapi-community.github.io/strapi-plugin-rest-cache/guide/strategy/cache-custom-routes.html

Let me know if that does what you needs

alex-whatagraph commented 1 year ago

I couldn't get this to work. Do you have an example config that I could try that caches queries to /articles, including pagination and fields returned. i.e. that would cache a query such as this:

/articles?fields[0]=id&fields[1]=title&fields[2]=slug&fields[3]=summary&populate[0]=coverImage&populate[1]=category&sort=publishedAt:desc&pagination[start]=1&pagination[limit]=12

Thanks

kutsan commented 1 year ago

I'd love to get help on this one too.