小编Eri*_*edo的帖子

当 NGINX 启用静态缓存内容时,网站不加载静态文件

我有一个运行 CentOS 和 NGINX/PHP-FPM 的 VPS。一切正常,除非我添加以下几行以启用静态缓存内容。如果我这样做,该页面不会加载那些指定保留缓存的文件。

   location ~* \.(ico|css|js|gif|jpg|jpeg|png)$ {
        expires 30d;
        add_header Vary Accept-Encoding;
        access_log off;
   }
Run Code Online (Sandbox Code Playgroud)

这是我的整个服务器{}:

server {
    listen        80;
    server_name  mywebsite.com www.mywebsite.com;

   #location ~* \.(ico|css|js|gif|jpg|jpeg|png)$ {
   #     expires 30d;
   #     add_header Vary Accept-Encoding;
   #     access_log off;
   #}

    location / {
        if ($http_host ~* "^www.(.*)$"){
            set $rule_0 1$rule_0;
            set $bref_1 $1;
        }
        if ($rule_0 = "1"){
           rewrite ^/(.*)$ http://$bref_1/$1 permanent;
        }
        rewrite ^/search/(.*)/(.*)/?$ /index.php?search=$1&page=$2&type=mp3 las$
        rewrite ^/(.*)/(.*)/(.*)?$ /index.php?search=$1&page=$2&type=$3 last;
        root   /var/www/mywebsite.com/public_html;
        index  index.php index.html index.htm;
    }

    location …
Run Code Online (Sandbox Code Playgroud)

nginx centos php-fpm

4
推荐指数
1
解决办法
1372
查看次数

标签 统计

centos ×1

nginx ×1

php-fpm ×1