Want more timely Centmin Mod News Updates?
Become a Member

Xenforo XenForo Media Gallery: nginx cache rewrite rule

Discussion in 'Forum software usage' started by nfn, Dec 1, 2016.

  1. nfn

    nfn New Member

    29
    0
    1
    Jun 28, 2015
    Ratings:
    +8
    Local Time:
    9:22 AM
    Hi

    When we have embedding media from the gallery inside posts, browser requests are redirected to the specific attachment image.

    wpt_media.png


    I was trying to cache these 301 redirect with nginx, but I can't get a way to do it ....

    Code:
        # Media Cache
        location  ^/media/(?:.+)/full(?:.+)$ {
            rewrite_log on;
            try_files $uri $uri/ /index.php?$uri&$args;
            fastcgi_cache fastcgicache;
            fastcgi_cache_valid 301 24h;
            fastcgi_cache_use_stale error timeout invalid_header updating http_500 http_503;
            fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
    
            location ~ \.php$ {
                add_header X-Media-Cache $upstream_cache_status;
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                include         fastcgi_params;
                fastcgi_index   index.php;
                fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param   SERVER_NAME $host;
                fastcgi_pass    php7-fpm;
                }
        }
    Can this be archived?
     
  2. eva2000

    eva2000 Administrator Staff Member

    55,153
    12,249
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,825
    Local Time:
    6:22 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Don't do that just let it be as 301 redirects are cached in visitors web browsers not server :)