nginx microcaching and ispconfig

Discussion in 'Installation/Configuration' started by iqpascal, Dec 24, 2019.

  1. iqpascal

    iqpascal Member

  2. Steini86

    Steini86 Active Member

    Have you tried: website -> options -> nginx directive ?
    If you want it for more websites, it may be a good idea to make it available via directive template (system -> directive snippets)
  3. iqpascal

    iqpascal Member

    I have added this line to nginx_vhost.conf.master:

    fastcgi_cache_path /var/cache/nginx2/<tmpl_var name='domain'> levels=1:2 keys_zone=<tmpl_var name='domain'>cache:5m max_size=1000m;

    And this to the nginx directive of 1 site:

    location / {
    index index.php index.html index.htm;
    if (!-e $request_filename) {
    rewrite ^(.+)$ /index.php?q=$1 last;
    location ~ \.php$ {
    # Setup var defaults
    set $no_cache "";
    # If non GET/HEAD, don't cache & mark user as uncacheable for 1 second via cookie
    if ($request_method !~ ^(GET|HEAD)$) {
    set $no_cache "1";
    # Drop no cache cookie if need be
    # (for some reason, add_header fails if included in prior if-block)
    if ($no_cache = "1") {
    add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/";
    add_header X-Microcachable "0";
    # Bypass cache if no-cache cookie is set
    if ($http_cookie ~* "_mcnc") {
    set $no_cache "1";
    # Bypass cache if flag is set
    fastcgi_no_cache $no_cache;
    fastcgi_cache_bypass $no_cache;
    fastcgi_cache test.nlcache;
    fastcgi_cache_key $server_name|$request_uri;
    fastcgi_cache_valid 404 30m;
    fastcgi_cache_valid 200 10s;
    fastcgi_max_temp_file_size 1M;
    fastcgi_cache_use_stale updating;
    fastcgi_pass_header Set-Cookie;
    fastcgi_pass_header Cookie;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    #fastcgi_intercept_errors on;
    include /etc/nginx/fastcgi_params;

    This seems to work

    However I do believe I cannot auto fill "fastcgi_cache" as {DOMAIN} is not a variable

Share This Page