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

Feature request: have a request bypass the cache #603

Open
teodorescuserban opened this issue Mar 5, 2025 · 1 comment
Open

Feature request: have a request bypass the cache #603

teodorescuserban opened this issue Mar 5, 2025 · 1 comment

Comments

@teodorescuserban
Copy link
Contributor

I am using caddy and souin as caddy plugin. I have a request from an app owner to be able to make request directly, skipping the cache if the request includes a custom header. I can do it really simple by altering the matcher (see my solution below), but this will bypass the cache module altogether. Ideally, I would like to have the cache module do its own bypass and send the headers (something like cache-status: cache; fwd=uri-miss; key=xxx; detail=BYPASS-REQUESTED).

Not sure how easy is this to implement across all integrations, but putting this out as an idea.

# caddy example
...
map {http.request.uri} {wants_cache} {
	default 0
	"~^/a1" 1
	"~^/a2" 1
}
...
map {http.request.header.some-custom-header} {bypass_cache} {
	default 1
	"" 0
}
...
@needs_cache expression `{wants_cache} == "1" && {bypass_cache} == "0"`
...
cache @needs_cache
...
@teodorescuserban teodorescuserban changed the title Feat request: have a request bypass the cache Feature request: have a request bypass the cache Mar 5, 2025
@darkweak
Copy link
Owner

@teodorescuserban that's currently not possible and I don't plan to implement this requested feature because I don't see the benefits.

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