js刷新304html页面,html – 利用浏览器缓存Nginx,重新加载页面时没有css

我正在努力遵循google pagespeed建议并利用浏览器缓存.为此,我将以下代码放入我的nginx.conf文件的服务器块中.

location ~* \.(jpg|jpeg|png|gif|ico|css|js)${

expires 365d;

}

location ~* \.(pdf)${

expires 30d;

}

它似乎工作得很好,页面速度将我的分数从87/100提高到95/100.但是,当我单击我的网站的刷新按钮时,它似乎不再加载css文件?

缓存不起作用吗?

我得到的错误信息是

Failed to load resource: the server responded with a status of 404 (Not Found)

这是我的整个nginx.conf文件

worker_processes 1;

events {

worker_connections 1024;

}

http {

include /etc/nginx/mime.types;

sendfile on;

gzip on;

gzip_http_version 1.0;

gzip_proxied any;

gzip_min_length 500;

gzip_disable "MSIE [1-6]\.";

gzip_types text/plain text/xml text/css

text/comma-separated-values

text/javascript

application/x-javascript

application/atom+xml;

# Configuration containing list of application servers

upstream app_servers {

server 127.0.0.1:8080;

}

# Configuration for Nginx

server {

# Running port

listen 80;

# Settings to serve static files

location /static/ {

# Example:

# root /full/path/to/application/static/file/dir;

root /var/www/benty-fields/app/;

}

location ~* \.(jpg|jpeg|png|gif|ico|css|js)${

expires 365d;

}

location ~* \.(pdf)${

expires 30d;

}

# Serve a static file (ex. favico)

# outside /static directory

location = /favico.ico {

root /app/favico.ico;

}

# Proxy connections to the application servers

# app_servers

location / {

proxy_pass http://app_servers;

proxy_redirect off;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Host $server_name;

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值