小编mak*_*eka的帖子

在 Nginx 的反向代理中添加对特定静态文件的缓存?

我想在客户端浏览器上使用 nginx 缓存单页应用程序的 js 和 css 文件。当我尝试当前注释掉的块时,指定的文件有 404 响应。尝试将块放入location / {块内,但发生了相同的错误。有人知道怎么修这个东西吗?帮助表示赞赏。

events {}

http {

gzip on;
gzip_vary on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_disable "MSIE [1-6]\.";

# security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

server {
    server_name SERVER_NAME www.SERVER_NAME;
    access_log  /var/log/nginx/access.log; …
Run Code Online (Sandbox Code Playgroud)

caching nginx single-page-application

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

标签 统计

caching ×1

nginx ×1

single-page-application ×1