Skip to content

Instantly share code, notes, and snippets.

@BurlesonBrad
Created August 18, 2017 21:09
Show Gist options
  • Save BurlesonBrad/5134a201e5533db38bf670f546fc9b90 to your computer and use it in GitHub Desktop.
Save BurlesonBrad/5134a201e5533db38bf670f546fc9b90 to your computer and use it in GitHub Desktop.
Aelia + NGINX + Cache
# Add Aelia cookies to the cache key. This will create multiple copies of each
# cached page (one for each combination of currency, country and province/state)
proxy_cache_key "$scheme$request_method$host$request_uri $cookie_aelia_cs_selected_currency$cookie_aelia_customer_country$cookie_aelia_customer_state$cookie_aelia_billing_country";
# IMPORTANT
# This is an example configuration file, and the settings apply to the entire server.
# You should probably adapt these settings to apply to a specific location, instead,
# so that they only affect your specific ecommerce site.
#
# If you are not familiar with Nginx configuration, we recommend to contact your
# developer, or hosting provider, who should be able to adjust the settings for you.
server {
listen 80;
server_name www.example.org;
set $no_cache 0;
# If none of the Aelia cookies are set, disable caching. This will ensure that
# the page is loaded dynamically, and that cookies are set at the next load
if ($cookie_aelia_cs_selected_currency$cookie_aelia_customer_country$cookie_aelia_customer_state$cookie_aelia_billing_country$cookie_aelia_tax_exempt ~* "") {
set $no_cache 1;
}
# Don't pull from cache based on $no_cache
fastcgi_cache_bypass $no_cache;
# Don't save to cache based on $no_cache
fastcgi_no_cache $no_cache;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment