Skip to content

Instantly share code, notes, and snippets.

@markwillis82
Created July 12, 2013 07:31
Show Gist options
  • Select an option

  • Save markwillis82/5982590 to your computer and use it in GitHub Desktop.

Select an option

Save markwillis82/5982590 to your computer and use it in GitHub Desktop.

Revisions

  1. Mark Willis created this gist Jul 12, 2013.
    61 changes: 61 additions & 0 deletions site.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,61 @@
    server {
    root /path/to/site;
    index index.php;
    server_name somedomain.co.uk www.somedomain.co.uk;

    set $cache_uri $request_uri;

    # POST requests and urls with a query string should always go to PHP
    if ($request_method = POST) {
    set $cache_uri 'null cache';
    }

    #loose any caching on querystring items
    if ($query_string != "") {
    set $cache_uri 'null cache';
    }

    add_header X-UA-Compatible IE=edge,chrome=1;

    error_page 418 = @nocache;
    recursive_error_pages on;

    location / {
    if ($http_cookie ~ 'noCache=1') {
    return 418;
    }
    if ($request_method = POST ) {
    return 418;
    }

    # try the statcache - otherwise use modx
    try_files /core/cache/statcache/web/$uri~index.html /core/cache/statcache/web/$uri $uri $uri/ @modx;
    }

    location @modx {
    rewrite ^/(.*)$ /index.php?q=$1&$args;
    }

    location @nocache {
    try_files $uri $uri/ @modx;
    }

    location ~ \.php$ {
    try_files $uri =404;

    set $skip_cache 1;
    if ($cache_uri != "null cache") {
    add_header X-Cache-Debug "$cache_uri $cookie_nocache $arg_nocache$arg_comment $http_pragma $http_authorization";
    set $skip_cache 0;
    }
    fastcgi_pass_header Set-Cookie;
    fastcgi_buffers 64 4k;

    include fastcgi_params;
    fastcgi_param production "true";
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_pass php5-fpm-sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
    }
    }