【发布时间】:2011-01-05 21:36:26
【问题描述】:
我正在使用下面的脚本来压缩一些 CSS 和 JS 文件。它工作得很好——除了提供内容类型错误的 JS 文件(而不是适当的应用程序/x-javascript)。我如何改进 PHP 代码以提供正确的内容类型?谢谢!
.htaccess:
AddHandler application/x-httpd-php .css .js
php_value auto_prepend_file gzip.php
gzip.php:
<?php
ob_start ("ob_gzhandler");
header("Content-type: text/css; charset: UTF-8");
header("Cache-Control: must-revalidate");
$offset = 60 * 60 ;
$ExpStr = "Expires: " .
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
?>
【问题讨论】:
标签: php .htaccess gzip content-type javascript