Nginx缓存在Laravel Forge服务器上不起作用

时间:2019-07-18 02:25:34

标签: nginx caching forge

也许我误会了应该怎么做,但这就是我的nginx配置文件的设置方式:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name site.com;
    root /home/forge/site.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/site.com/417475/server.crt;
    ssl_certificate_key /etc/nginx/ssl/site.com/417475/server.key;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DO NOT REMOVE!)
    include forge-conf/site.com/server/*;

    gzip on;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/site.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }

    location ~* \.(eot|ttf|woff|woff2)$ {
        expires 365d;
        add_header Pragma "public";
        add_header Cache-Control "public";
        add_header Access-Control-Allow-Origin *;
    }

    location ~* .(ico|css|js|gif|jpeg|jpg|png|otf|svg)$ {
        expires 365d;
        add_header Pragma "public";
        add_header Cache-Control "public";
    }
}

当我通过GTmetrix运行站点时,在“利用浏览器缓存”下获得F等级。该类别下列出的文件是:

https://js.intercomcdn.com/shim.latest.js (5 minutes)
https://js.stripe.com/v3/ (5 minutes)
https://connect.facebook.net/en_US/fbevents.js (20 minutes)
https://connect.facebook.net/en_US/sdk.js (20 minutes)
https://connect.facebook.net/signals/config/?v=2.8.51&r=stable (20 minutes)
https://connect.facebook.net/signals/plugins/inferredEvents.js?v=2.8.51 (20 minutes)
https://cdn.site.com/site/header/picture-1.jpg (26 minutes 38 seconds)
https://cdn.site.com/site/header/picture-2.jpg (26 minutes 38 seconds)
https://cdn.site.com/site/misc/picture-3.png (26 minutes 38 seconds)
https://cdn.site.com/site/header/picture-4.jpg (26 minutes 39 seconds)
https://apis.google.com/js/platform.js (30 minutes)
https://cdn.site.com/products/picture-5.jpg (41 minutes 38 seconds)
https://cdn.site.com/products/picture-6.jpg (41 minutes 38 seconds)
https://cdn.site.com/products/picture-7.jpg (41 minutes 38 seconds)
https://www.google-analytics.com/plugins/ua/ec.js (1 hour)
https://www.googleadservices.com/pagead/conversion_async.js (1 hour)
https://s.pinimg.com/ct/core.js (2 hours)
https://www.google-analytics.com/analytics.js (2 hours)

这些文件不是大多数情况下都在1年内到期吗?

location ~* .(ico|css|js|gif|jpeg|jpg|png|otf|svg)$

0 个答案:

没有答案