Closed skrlance closed 7 months ago
Hello @skrlance thank you for your feedback. The regex directive is defined as the following Regexp that the URI should match to override the key generation
so that's a regex on the path, not on anything in the request. AFAIK you cannot exclude the 301/302 http status codes from being cached because the RFC allows it.
There is something more I need to say like you know almost 40% of web is powered by WordPress. There are lots of people like me ditching NGINX and running WordPress using Caddy 2 server. So, these days cache is main agenda in WordPress in case of performance. For that purpose, most people using Caddy server for WordPress will use Souin Cache also.
In this view point, I don't see you kept any example configuration of Souin Cache for WordPress website. So, this is why this problem has arise.
Can you please help all WordPress users keeping example configuration of Souin Cache in Caddy server for WordPress websites?
Thanks Kindly
Let me a couple of hour to work on an example and add it to the https://docs.souin.io/docs/use-cases/ 🙂
Keep on this location also:
https://github.com/darkweak/souin/tree/master/plugins/caddy/examples
Thanks
Where have you excluded the following things from cache?
header_regexp Cookie "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in"
path_regexp "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(index)?.xml|[a-z0-9-]+-sitemap([0-9]+)?.xml)"
method POST
expression {query} != ''
Regards
@skrlance I updated the documentation with the following Caddyfile
{
default_sni {$SERVER_NAME}
order cache before rewrite
cache {
api {
souin
}
}
}
{$SERVER_NAME} {
+ @authorized-cache {
+ not header_regexp Cookie "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in"
+ not path_regexp "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(index)?.xml|[a-z0-9-]+-sitemap([0-9]+)?.xml)"
+ not method POST
+ not expression {query} != ''
+ }
+ cache @authorized-cache
root * /var/www/html
encode zstd gzip
php_fastcgi wordpress:9000
file_server
log {
output file /var/log/caddy.log
}
header / {
X-Frame-Options "SAMEORIGIN"
X-Content-Type-Options "nosniff"
}
}
Oh I see! This is how it works! Thank you very much!!
You can mark this issue resolved! But still if you find someway to exclude the redirects especially 301 and 302, please let us know!
@skrlance If your upstream can return a header Cache-Control: no-cache
it could do the trick.
@skrlance If your upstream can return a header
Cache-Control: no-cache
it could do the trick.
Thanks! I will do that. Please mark this issue resolved!!
Souin cache is currently speeding up my website with Caddy server. After I saw that it caches redirects also and all redirects like 301 and 302 doesn't works, I have configured it in the following way:
By this way, many other redirects are working excluding the mentioned paths. However, still on those match and match1 paths no 301 or 302 redirects works. So, I tried the following way in the global option:
However, the above code also didn't prevented the redirects from being cached.
So, I tried every other way on the server option like:
But, still nothing is preventing redirects from being cached. What to do?
Please help me in this!