可以做“相对”的事情 HTTP 标头过期?
例如,我希望我的静态文件在首次下载后 7 天过期。 我应该将 Expires 标头值设置为多少?
For example, I want my static files to expire 7 days after they're first downloaded. What should I set the Expires header value to be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只是偶然发现了这个试图找到其他东西 - 但在这种情况下你不应该使用 Expires。 使用 Cache-Control:
(604800 是 7 天(以秒为单位))。
Just stumbled across this trying to find something else — but you shouldn’t be using Expires in this case. Use Cache-Control:
(604800 is 7 days in seconds).
您需要在服务器端执行此操作。 生成计算该值的时间戳,然后发送回包含该值的标头。
PHP 示例
You need to do this server side. Generate the timestamp calculating the value, then send back the header with that value.
Example with PHP