Nginx配置Cache-Control后仍不生效的问题求助
Nginx配置Cache-Control后仍不生效的问题求助
大家好,最近我在用WebPageTest和PageSpeed做网站性能优化,结果这两个工具都提示我没有实现Cache-Control缓存控制,可我明明已经在Nginx配置里加了相关规则,试了好多次都没解决,有没有大佬能帮我看看哪里出问题了?
下面是我的Nginx配置代码:
server { #listen 80; root /var/www/html/public; index index.html index.htm index.php; server_name thewebsite.com; # managed by Certbot location ~* \.(js|css|png|jpg|webp)$ { expires 1M; add_header Cache-Control "max-age=2629746, public"; } location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; } location = /livewire/livewire.js { expires off; try_files $uri $uri/ /index.php?$query_string; } location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; deny all; } } # Expires map map $sent_http_content_type $expires { default off; text/html epoch; text/css max; application/javascript max; ~image/ epoch; } server { location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; deny all; } listen 80 ; server_name thewebsite.com; return 404; # managed by Certbot expires $expires; }
麻烦各位帮忙排查下问题,谢谢啦!
备注:内容来源于stack exchange,提问作者magicianiam
相关产品推荐
相关产品推荐

