我的页面包含静态内容(.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小时重新生成一次。
答案 0 :(得分:0)
<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>