location ~ .*\.(js|css)?$ { add_header Cache-Control "max-age=604800, public"; expires 7d; access_log off; } 是什么意思
时间: 2024-06-11 10:08:33 浏览: 252
这是一个Nginx服务器的配置文件中的一个location块,它的意思是:
对于请求的URI以.js或.css结尾的资源,设置响应头Cache-Control的值为"max-age=604800, public",即浏览器可以缓存这些资源并在一周内无需再次请求,同时设置过期时间为7天,并关闭访问日志记录。
相关问题
location ~ .*\.(js|css)?$ { expires 7d; access_log off; }
This configuration block is used in Nginx server to set the cache-control headers for JavaScript (.js) and CSS (.css) files.
The "location" directive is used to define a location that matches the regular expression. In this case, the regular expression is ".*\.(js|css)?$", which matches any URI that ends with ".js" or ".css".
The "expires" directive is used to set the cache expiration time for the matched files. In this case, the expiration time is set to 7 days. This means that the browser will cache the files for 7 days before checking for updates.
The "access_log" directive is used to turn off logging for the matched files. This means that access to these files will not be logged in the Nginx access log.
Overall, this configuration block is used to optimize the performance of the server by caching JavaScript and CSS files and reducing the number of requests to the server.
伪静态nginx的location ~ .*.(?:htm|html)${root ydj expires -1;add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate"; }转换为apache
在Apache中,您可以使用以下代码转换伪静态nginx的location ~ .*.(?:htm|html)$配置:
```
<FilesMatch "\.(htm|html)$">
Header set Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate"
ExpiresActive On
ExpiresDefault "access plus -1 seconds"
</FilesMatch>
```
阅读全文