Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP Cache-Control and params order

Why browsers cache data, don't send request to server, only if query parameters in url are in same order?

For example if request to

/product?q=phone&cat=1

send in response header Cache-Control:max-age=60

the next request

/product?cat=1&q=phone

request is send to server, but should retrieve data from cache

Also some frameworks recommend

If you are caching requests that use a large number of query string parameters, consider sorting them to ensure that the request is properly cached.

By ordering your params, you can be sure the cache key will be consistent across requests and you are caching effectively.

like image 994
Romper Avatar asked Feb 05 '23 11:02

Romper


1 Answers

HTTP doesn't define the syntax of query parameters. So from the cache's point of view, these URLs might identify different content.

like image 129
Julian Reschke Avatar answered Feb 23 '23 15:02

Julian Reschke