Learn about Centmin Mod LEMP Stack today
Register Now

Xenforo XenForo Media Gallery: nginx cache rewrite rule

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

  1. nfn

    nfn New Member

    11
    0
    1
    Jun 28, 2015
    Ratings:
    +0
    Local Time:
    6:54 PM
    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

    29,029
    6,588
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,780
    Local Time:
    3:54 AM
    Nginx 1.13.x
    MariaDB 5.5
    Don't do that just let it be as 301 redirects are cached in visitors web browsers not server :)