Next.js Discord

Discord Forum

Cache graphql queries

Unanswered
American Shorthair posted this in #help-forum
Open in Discord
American ShorthairOP
Hi, I have a product filter that depending on search parameters, makes a query to backend via graphql. I want to cache these queries, problem is:
I know I can cache by URL, for example my URL where this filter is localhost:3000/products, but these queries depends on search parameters from product filter, let's say size, color etc., can I somehow cache graphql queries by product filter? meaning, URL will stay the same, but one query will have color "red", other one will have "orange", I want these both queries cached.

Another variant would be to add product filter parameters to URL parameters, example: localhost:3000/products?c=red, perhaps I could cache queries this way? what would be the best approach here? Thanks.

0 Replies