Skip to content

Commit

Permalink
Fix 404s by moving skip_cache conditions to server block
Browse files Browse the repository at this point in the history
  • Loading branch information
fullyint committed Dec 1, 2016
1 parent 78400a9 commit b961f8c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### HEAD
* Fix 404s by moving skip_cache conditions to server block ([#692](https://github.com/roots/trellis/pull/692))
* Nginx includes: Move templates dir, fix 'No such file' error ([#687](https://github.com/roots/trellis/pull/687))
* [BREAKING] Move shell scripts to bin/ directory ([#680](https://github.com/roots/trellis/pull/680))
* Add myhostname to nsswitch.conf to ensure resolvable hostname ([#686](https://github.com/roots/trellis/pull/686))
Expand Down
37 changes: 19 additions & 18 deletions roles/wordpress-setup/templates/wordpress-site.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,31 @@ server {
include acme-challenge-location.conf;
{% endif %}

include includes.d/{{ item.key }}/*.conf;
include wordpress.conf;
{% if item.value.cache is defined and item.value.cache.enabled | default(false) -%}
set $skip_cache 0;

location ~ \.php$ {
try_files $uri =404;
error_page 404 /index.php;
if ($query_string != "") {
set $skip_cache 1;
}

{% if item.value.cache is defined and item.value.cache.enabled | default(false) -%}
set $skip_cache 0;
# Don't cache uris containing the following segments
if ($request_uri ~* "{{ item.value.cache.skip_cache_uri | default(nginx_skip_cache_uri) }}") {
set $skip_cache 1;
}

if ($query_string != "") {
set $skip_cache 1;
}
# Don't use the cache if cookies includes the following
if ($http_cookie ~* "{{ item.value.cache.skip_cache_cookie | default(nginx_skip_cache_cookie) }}") {
set $skip_cache 1;
}
{% endif -%}

# Don't cache uris containing the following segments
if ($request_uri ~* "{{ item.value.cache.skip_cache_uri | default(nginx_skip_cache_uri) }}") {
set $skip_cache 1;
}
include includes.d/{{ item.key }}/*.conf;
include wordpress.conf;

# Don't use the cache if cookies includes the following
if ($http_cookie ~* "{{ item.value.cache.skip_cache_cookie | default(nginx_skip_cache_cookie) }}") {
set $skip_cache 1;
}
location ~ \.php$ {
try_files $uri /index.php;

{% if item.value.cache is defined and item.value.cache.enabled | default(false) -%}
fastcgi_cache wordpress;
fastcgi_cache_valid {{ item.value.cache.duration | default(nginx_cache_duration) }};
fastcgi_cache_bypass $skip_cache;
Expand Down

0 comments on commit b961f8c

Please sign in to comment.