Skip to content

Commit f0695e8

Browse files
author
Alexandros Ioannides
authored
Exclude caching for some admin sessions
Do not cache logged in users for WordPress, Drupal, Joomla and MODX. Othres will be covered through session cookie as well but not guaranteed.
1 parent 22d1b8b commit f0695e8

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

install/deb/templates/web/nginx/caching.stpl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,22 @@ server {
1818
proxy_pass https://%ip%:%web_ssl_port%;
1919

2020
proxy_cache %domain%;
21-
proxy_cache_valid 15m;
22-
proxy_cache_valid 404 1m;
21+
proxy_cache_valid 200 5m;
22+
proxy_cache_valid 301 302 10m;
23+
proxy_cache_valid 404 10m;
24+
proxy_cache_bypass $no_cache $cookie_session $http_x_update;
2325
proxy_no_cache $no_cache;
24-
proxy_cache_bypass $no_cache;
25-
proxy_cache_bypass $cookie_session $http_x_update;
26+
27+
set $no_cache 0;
28+
if ($request_uri ~* "/wp-admin/|wp-.*.php|xmlrpc.php|index.php|/store.*|/cart.*|/my-account.*|/checkout.*|/user/|/admin/|/administrator/|/manager/|index.php") {
29+
set $no_cache 1;
30+
}
31+
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_items_in_cart|woocommerce_cart_hash|PHPSESSID") {
32+
set $no_cache 1;
33+
}
34+
if ($http_cookie ~ SESS) {
35+
set $no_cache 1;
36+
}
2637

2738
location ~* ^.+\.(%proxy_extensions%)$ {
2839
proxy_cache off;

0 commit comments

Comments
 (0)