Skip to content

Instantly share code, notes, and snippets.

@sepiariver
Created May 19, 2016 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sepiariver/74f5534b110b5dc08a527f7cc74f0c29 to your computer and use it in GitHub Desktop.
Save sepiariver/74f5534b110b5dc08a527f7cc74f0c29 to your computer and use it in GitHub Desktop.
Web Rules (nginx conf) in MODX Cloud for CDN, proxy caching assets, and statcache
# statcache bits
set $cache_prefix 'statcache';
if ($http_user_agent = 'MODX RegenCache') {
set $cache_prefix 'no cache';
}
# CORS for CDN pull zone and expires directives
location ~* \.(?:ico|css|js|jpe?g|png|gif|svg|pdf|mov|mp4|mp3|woff|woff2|ttf|ttc|otf|eot|font.css)$ {
expires 7d;
add_header Access-Control-Allow-Origin "*";
add_header Pragma public;
add_header Cache-Control "public";
gzip_vary on;
}
# modified modx rewrite for statcache
location / {
try_files /$cache_prefix$uri~index.html /$cache_prefix$uri $uri $uri/ @modx-rewrite;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment