Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 404s by moving skip_cache conditions to server block #692

Merged
merged 1 commit into from
Dec 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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