缓存一些文件,而不是其他文件
Cache some files, not the others
我的页面包含静态内容 (.jpg) 和服务器端缓存内容 (.jpg 也是)。
<body>
// Static content, "never change"
<img src="my_static_image.jpg">
// This image change every 6 hours, its name will not change.
<img src="changing_image.jpg">
<body>
我想优化加载和刷新仅更改的内容,而不是其余内容。
在我的例子中,changing_image.jpg 保持相同的名称,但在服务器端每 6 小时重新生成一次。
<FilesMatch "/static/"> <-- this is regex, you can match by filename rather than by extention
Header set Cache-Control "max-age=29030400, public" <-- longer
</FilesMatch>
<FilesMatch "/changing/"> <-- this is regex, you can match by filename rather than by extention
Header set Cache-Control "max-age=21600, public" <--6 hours in seconds
</FilesMatch>
我的页面包含静态内容 (.jpg) 和服务器端缓存内容 (.jpg 也是)。
<body>
// Static content, "never change"
<img src="my_static_image.jpg">
// This image change every 6 hours, its name will not change.
<img src="changing_image.jpg">
<body>
我想优化加载和刷新仅更改的内容,而不是其余内容。 在我的例子中,changing_image.jpg 保持相同的名称,但在服务器端每 6 小时重新生成一次。
<FilesMatch "/static/"> <-- this is regex, you can match by filename rather than by extention
Header set Cache-Control "max-age=29030400, public" <-- longer
</FilesMatch>
<FilesMatch "/changing/"> <-- this is regex, you can match by filename rather than by extention
Header set Cache-Control "max-age=21600, public" <--6 hours in seconds
</FilesMatch>