php - 替代 mod_expires 来设置过期 header ?

标签 php apache .htaccess caching

我在 Apache 服务器上使用 php。我无法在我正在使用的服务器上的 .htaccess 中设置过期 header ,因为它是共享服务器,并且它们(网络主机)不会在 apache 构建中安装 mod_expires 模块。 我一直使用 ExpiresActive On 并为 .htaccess 中的图像、jsxml 和文本文件设置默认缓存过期时间 文件。

我还有哪些其他选择?

谢谢。

最佳答案

您可以使用 .htaccess 而无需 mod_expires。

<IfModule mod_headers.c>
  <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
    Header set Expires "Wed, 15 Apr 2020 20:00:00 GMT"
    Header set Cache-Control "public"
  </FilesMatch>
</IfModule>

关于php - 替代 mod_expires 来设置过期 header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1966524/

相关文章:

apache - 如果域匹配则设置 cookie

php - 如何使用Phalcon获取最后的插入ID?

php - Chrome 的滚动延迟

php - TYPO3:有没有办法在 Alt-Doc 表单中使用 javascript?

php - PDO错误:SQLSTATE[42000]: Syntax error or access violation: 1064

linux - Apache 虚拟主机配置

java - 如何使用 Apache POI 在不同行创建多个自动筛选器

.htaccess - gzip 工作但 YSlow 表明它不是

apache - .htaccess 重写测试失败

php - Slim 框架报错 apache