php - 如何为 css.php 设置过期 header ?

标签 php css performance mod-expires expires-header

我使用 Zend 框架,我有很多这样的 CSS 文件

http://www.example.com/css.php?request=application%2Fthemes%2Flove%2Ftheme.css&c=2146&pageStart=15376&pageEnd=256358

如何为 css.php 设置过期 header ? 事实上,我的 .htaccess 不支持它。

我的.htacess:

<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year”
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access 1 month”
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>

谢谢

最佳答案

请在 .htaccess 中尝试以下操作

    <IfModule mod_headers.c>
  <filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$">
  Header set Cache-Control "max-age=2678400, public"
  </filesmatch>
  <filesmatch "\.(html|htm)$">
  Header set Cache-Control "max-age=7200, private, must-revalidate"
  </filesmatch>
  <filesmatch "\.(pdf)$">
  Header set Cache-Control "max-age=86400, public"
  </filesmatch>
  <filesmatch "\.(js)$">
  Header set Cache-Control "max-age=2678400, private"
  </filesmatch>
</IfModule>

关于php - 如何为 css.php 设置过期 header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38243507/

相关文章:

PHP:未连接到数据库

PHP elseif 不起作用。(比较运算符与整数)

PHPExcel将字符串日期放入.xls

html - Bootstrap 不起作用的每列的单独滚动面板

html - 如何使 CITE 标签完全缩进?

.NET LINQ 查询语法与方法链

java - 为什么 "new"关键字比赋值效率高这么多?

php - 每次我使用内容 :"\005B"它都会变成内容 :"�05B"

css - div float 属性解释

c# - 在 task.Factory.FromAsync 中包装 WCF 异步调用不返回任何结果