paoloricciuti / sveltekit-search-params

The easiest way to read and WRITE from query parameters in sveltekit.
https://sveltekit-search-params.netlify.app
MIT License
478 stars 13 forks source link

sort params in url to improve browser cache hit rate #51

Closed dominikg closed 8 months ago

dominikg commented 8 months ago

Describe the problem

With optional parameters it is currently possible to add them at different times, and their insertion order determines their position in the query string of the url.

http caching uses the full url , so https://example.com?a=1&b=2 is a different entry than https://example.com?b=2&a=1 In order to have a more stable url representation and improve cache hit rate, it would be great if the params can be sorted.

Describe the proposed solution

use native sort() by default, add an option for custom sort function (or false to disable)