Comments (5)
That makes sense, thanks for the clarification. Maybe the documentation could make this clearer if it were structured along the lines of:
When the
cache
plugin is enabled, any responses containing headersA
,B
, orC
will be cached, except when<RFC>
indicates they should not be. In addition, the presence ofmatch_path
instructs the plugin to cache matching responses even withoutA
,B
, orC
.
from caddy-cache.
Maybe I should update the documentation, but the idea is to always respect the headers. The "basic usage" (if you specify a path in the config) is just a "hint".
For example: if you add /api
, it means to be cached unless a header specifies otherwise. It doesn't override what headers indicate. If /public
has a cache-control
it will be cached even if it wasn't specified in the config. What it changes when you specify a path in the config is that if /api
doesn't has any header, it will be cached.
I hope this clarifies how it works.
from caddy-cache.
I ran into this issue as well. In combo with issue #28, it resulted in the unexpected behavior of serving up empty 304 responses 😮.
I think it's confusing because the label syntax in many other Caddy plugins is activated based on the path. For example: proxy /explicit_path localhost:8080 { ... }
.
Confusion results because the label syntax in the cache
plugin is opt-out and not based on the path. The naming of the directive match_path
doesn't help, because on skimming the docs, it makes it appear to be opt-in and based on the path.
from caddy-cache.
@csytan The idea was to be able to use it without configure anything and use cache headers. I'm sorry if that's not how it looks. I wanted to offer both ways to enable it: header based rules and config based rules (becase maybe you don't control headers or what a simpler way). What would it be the ideal caddyfile for you having that in mind? (#28 was already solved)
from caddy-cache.
@nicolasazrak I think a path based approach would be easier to understand. For example:
cache /my_website {
except /my_website/do_not_cache_this_path
}
For backwards compatibility, if no is path specified, then cache every path:
cache {
...
}
# above is equivalent to:
cache / {
...
}
match_path
would be even more confusing at first glance. Perhaps re-naming it to something like cache_path_without_header
, force_cache_path
, or force_cache
would be more obvious. Also deprecating match_path
in a future version.
P.S. Thank you for working on this project. Looking forward to trying the fix for #28 👍
from caddy-cache.
Related Issues (20)
- Add a configuration to not use query params in cache key. HOT 2
- caddy-cache relative cache paths do not respect the root directive HOT 1
- New release? HOT 1
- How to control cached files http header? HOT 5
- How to only cache data with status 200 HOT 2
- Http: multiple response.WriteHeader calls HOT 9
- Large file request
- http2 Push Dosn't work with cache plugin HOT 1
- RFC 7234: Prefer value from Cache-Control: s-maxage HOT 1
- RFC 5861 Cache-Control Extensions for Stale Content (async cache refresh) HOT 2
- LGPL Licence HOT 6
- Memory leak HOT 4
- Cached file is deleted from /tmp dir HOT 1
- HLS M3U8 Caching HOT 1
- Static website cache HOT 1
- Caddy's import path has changed
- Header modification conflict
- Conflicts with cors plugin HOT 1
- "superfluous response.WriteHeader" and "wrote more than the declared Content-Length" HOT 1
- 'cache' directive not recognized HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from caddy-cache.