添加没有mod_expires的expires头?

Seb*_*ebi 7 apache .htaccess mod-expires

我知道我可以使用mod_expires添加expires头.但是,如果Apache服务器没有安装mod_expires并且我不想通过像PHP这样的脚本语言来访问文件,我该怎么办?

Gum*_*mbo 7

您可以使用mod_header手动设置标题字段:

Header set Expires "..."
Run Code Online (Sandbox Code Playgroud)

但由于Expires需要一个绝对时间,因此使用Cache-Controlmax-age参数来计算相对于访问时间的时间:

Header merge Cache-Control max-age=3600
Run Code Online (Sandbox Code Playgroud)