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

Can't purge a specific key if the key name include a question mark #594

Open
teodorescuserban opened this issue Jan 21, 2025 · 2 comments
Open

Comments

@teodorescuserban
Copy link

Hello, I am using souin cache as caddy module.

/etc/caddy # caddy version
v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=
/etc/caddy # caddy build-info | grep souin
dep     github.com/darkweak/souin       v1.7.5  h1:drNhZc0GhSbGcugiGfcYdLDTcx3DCZW6o13wwRj5o5Y=
/etc/caddy # caddy build-info | grep stora
dep     github.com/darkweak/storages/core       v0.0.11 h1:IwvpAtkhOmxC5pIffJ8opW6erpTnIi5zqPveiAQs8ew=
dep     github.com/darkweak/storages/go-redis   v0.0.11 h1:2IjIEPREWyooSAq4syKeFq/yeia5sPnaypzs/GK3tRo=
dep     github.com/darkweak/storages/go-redis/caddy     v0.0.11 h1:d6qQRAzOJLSmQkLXEW/XVTAkh/C0kofPP3LxoP9djWs=

My cache key template is template {http.request.uri}.

I noticed while testing purging that I am unable to purge from cache only a single key if it contains the questionmark between the url.path and the url.query.

Example url: localhost/v3/viewLog?day=1
Cache key: /v3/viewLog?day=1 (as seen in redis and when I GET the souin api)
Cannot remove by: curl -X PURGE localhost/souin-api/souin//v3/viewLog?day=1 or curl -X PURGE localhost/souin-api/souin/v3/viewLog?day=1

Hoever, if I change the cache key template from {http.request.uri} to {http.request.uri.path}--{http.request.uri.query}, I am able to purge the cache key /v3/viewLog--day=1 by curl -X PURGE localhost/souin-api/souin/v3/viewLog--day=1.

I also tried (unsuccessfully) to escape the questionmark by curl -X PURGE localhost/souin-api/souin/v3/viewLog\?day=1.

What I am missing?

Thank you!

@teodorescuserban teodorescuserban changed the title Question mark in the key name makes the key stick Can't purge a specific key if the key name include a question mark Jan 22, 2025
@darkweak
Copy link
Owner

Hello @teodorescuserban I didn't think about special characters in the key, I will have time today to write a patch for that.

@teodorescuserban
Copy link
Author

teodorescuserban commented Jan 22, 2025

Actually I re-tested it and it does work if you escape the question mark and enclose the whole url in double quotes like so curl -X PURGE "localhost/souin-api/souin/v3/viewLog\?day=1".

I guess not having to escape the question mark would still be super useful as you can copy paste the request directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants