Skip to content

Commit 02cc52d

Browse files
retlehsclaude
andauthored
Fix fastcgi cache caching redirect responses (#1641)
Scope fastcgi_cache_valid to 200 responses only, preventing nginx from caching 301/302 redirects which can cause redirect loops when cached redirect target points back through WordPress/canonical redirects. Also add $upstream_http_location to fastcgi_no_cache as an additional guard against caching any response with a Location header. Closes #1594 Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4ad3723 commit 02cc52d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

roles/wordpress-setup/templates/wordpress-site.conf.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ server {
252252
{% if fastcgi_cache_enabled -%}
253253
# Fastcgi cache settings
254254
fastcgi_cache wordpress;
255-
fastcgi_cache_valid {{ item.value.cache.duration | default(nginx_cache_duration) }};
255+
fastcgi_cache_valid 200 {{ item.value.cache.duration | default(nginx_cache_duration) }};
256256
fastcgi_cache_bypass $skip_cache;
257-
fastcgi_no_cache $skip_cache;
257+
fastcgi_no_cache $skip_cache $upstream_http_location;
258258
fastcgi_cache_background_update {{ item.value.cache.background_update | default(nginx_cache_background_update) }};
259259

260260
{% endif -%}

0 commit comments

Comments
 (0)