Skip to content

Commit 97becce

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 f0695e8 commit 97becce

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,22 @@ server {
1313
proxy_pass http://%ip%:%web_port%;
1414
1515
proxy_cache %domain%;
16-
proxy_cache_valid 15m;
17-
proxy_cache_valid 404 1m;
16+
proxy_cache_valid 200 5m;
17+
proxy_cache_valid 301 302 10m;
18+
proxy_cache_valid 404 10m;
19+
proxy_cache_bypass $no_cache $cookie_session $http_x_update;
1820
proxy_no_cache $no_cache;
19-
proxy_cache_bypass $no_cache;
20-
proxy_cache_bypass $cookie_session $http_x_update;
21+
22+
set $no_cache 0;
23+
if ($request_uri ~* "/wp-admin/|wp-.*.php|xmlrpc.php|index.php|/store.*|/cart.*|/my-account.*|/checkout.*|/user/|/admin/|/administrator/|/manager/|index.php") {
24+
set $no_cache 1;
25+
}
26+
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") {
27+
set $no_cache 1;
28+
}
29+
if ($http_cookie ~ SESS) {
30+
set $no_cache 1;
31+
}
2132

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

0 commit comments

Comments
 (0)