Comments (9)
@ishuvalov Got it, thanks. I will defer to @darkweak on this.
(FYI, HTTP header Pragma
is obsolete HTTP/1.0, and most servers these days won't support it. You should use Cache-Control instead.)
from cache-handler.
Here is my config. (I find YAML more human friendly than JSON)
apps:
http:
servers:
srv_cache_api:
listen:
- :2020
routes:
- match:
- path:
- /cache-api*
handle:
- handler: cache
srv_main:
listen:
- :80
automatic_https:
disable: true
disable_redirects: true
routes:
- handle:
- handler: cache
- handler: encode
encodings:
gzip: {}
zstd: {}
prefer:
- zstd
- gzip
- handler: reverse_proxy
upstreams:
- dial: "#{$UPSTREAM}"
logs:
default_logger_name: log0
cache:
TTL: 1m
stale: 1m
log_level: INFO
api:
basepath: /cache-api
souin:
basepath: /souin
enable: true
prometheus:
basepath: /prometheus
enable: true
logging:
logs:
default:
writer:
output: stdout
level: INFO
exclude:
- http.log.access.log0
error_log:
writer:
output: stderr
level: ERROR
access:
writer:
filename: /var/log/caddy/access.log
output: file
level: INFO
include:
- http.log.access.log0
admin:
listen: 0.0.0.0:2019
I also would like to mention, that I tried do build Caddy with two variants of plugin:
xcaddy build --with github.com/caddyserver/cache-handler
- this one always returns 200 when missing the upstream, even ignoring "Pragma: no-cache" header
xcaddy build --with github.com/darkweak/souin/plugins/caddy
- this returns statuses like in examples I've posted above.
I hope this helps. Thanks.
from cache-handler.
Works like a charm. Thanks again! 👏
from cache-handler.
That sounds like Caddy's default response. Chances are a misconfiguration... What is your config and what is a curl -v
command that reproduces the 200 response?
(Then again, it could also very well be a bug in the cache handler. 🤷♂️)
from cache-handler.
Thank you for the reply.
If I remove cache handler from the handlers chain, I get normal 502 from missing upstream.
A also experimented with curl
:
$ curl -v http://localhost/
* Trying 127.0.0.1:80...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: Caddy
< Date: Mon, 21 Mar 2022 15:16:21 GMT
< Content-Length: 0
<
* Connection #0 to host localhost left intact
And doing this way I get proper 502.
$ curl -v -H "Pragma: no-cache" http://localhost/
* Trying 127.0.0.1:80...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/7.79.1
> Accept: */*
> Pragma: no-cache
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 502 Bad Gateway
< Cache-Status: Souin; fwd=uri-miss
< Server: Caddy
< Date: Mon, 21 Mar 2022 15:19:09 GMT
< Content-Length: 0
<
* Connection #0 to host localhost left intact
from cache-handler.
Ok, thanks. But what is your config?
from cache-handler.
The linked PR should fix that directly on Souin.
from cache-handler.
Thank you very much! 🙏
from cache-handler.
@ishuvalov you can use xcaddy build --with github.com/darkweak/souin/plugins/caddy@master
or xcaddy build --with github.com/darkweak/souin/plugins/caddy@latest
to see the working fix 😉
from cache-handler.
Related Issues (20)
- http.handlers.cache Reused response from concurrent request with HOT 1
- How to remove listening port (5443) and protocol scheme (http/https) from the cache_key when it is not regular port while preserving the hostname? HOT 7
- Using cache-handler in production HOT 9
- http.handlers.cache Reused response from concurrent request with the key... HOT 2
- Support NutsDB In Memory mode HOT 1
- Impossible to open the Nuts DB.db.buildIndexes error: crc error HOT 5
- Redis with Large Cached Content Fails Resulting in Memory Leak HOT 2
- Disable Request Coalescing HOT 9
- Impossible to set value into Badger, Value with size 1048681 exceeded 1048576 limit
- Impossible to set value into Redis, invalid expire time in 'set' command HOT 6
- Cache miss on cached requests HOT 4
- CRASH: panic: Header called after Handler finished - /souin/pkg/middleware.(*SouinBaseHandler).Upstream.func1() HOT 1
- runtime error: invalid memory address or nil pointer dereference HOT 1
- Impossible to get the mapping key in Otter HOT 1
- nutsdb: server hang without log HOT 2
- Panics with Redis cache enabled HOT 2
- Clarify difference between this and Souin in README.md HOT 1
- Cache TTL seems to be overwritten by cache control headers HOT 9
- UNIX socket support for redis `url` HOT 6
- Segmentation violation Caddy Cache module 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 cache-handler.