Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize query string parameters before hashing #426

Merged
merged 3 commits into from
Jan 23, 2023

Conversation

cosmastech
Copy link
Contributor

When the URL is hashed, it relies on Request@getRequestUri(). This does not normal query parameters, so a request for https://spatie.be/cached-pages?page=1&per_page=10 is not the same as https://spatie.be/cached-pages?per_page=10&page=1 (or even https://spatie.be/cached-pages?page=1&per_page=10&)

By normalizing the parameters this reduces cache misses for what is ultimately the same content.

Copy link
Contributor Author

@cosmastech cosmastech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning this up! I just copied the code from Request@getUri() but I prefer the verbosity.

Is there a code formatter you use for projects? Wasn't sure if there was a pint config or anything 😃

@freekmurze
Copy link
Member

Thanks! We'll update this package to use Pint for formatting soon.

@freekmurze freekmurze merged commit 263761a into spatie:main Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants