htaccess 的 AddHandler 规则的替代方案不起作用
为了帮助朋友在这里翻译他的问题:
在我将其包含在 .htaccess AddHandler application/x-httpd-php5s .php .js .css
中之前,目的是使用相同的 PHP 我可以创建缓存和压缩的规则。我所做的就是修改 php.ini 文件中的 auto_prepend_file,将其指向 PHP 文件,并通过那里检查标头 $_SERVER["HTTP_IF_MODIFIED_SINCE"] 中浏览器发送的变量。
如果日期不同,我会用标头(“HTTP/1.1 200 OK”)回答,这将发送压缩的 JS 或 CSS 文件。 如果日期相同,那么我会发送一个标头(“HTTP/1.1 304 Not Modified”),并且浏览器不必下载有问题的 JS 或 CSS 文件。
由于某种原因,.htaccess 中的 AddHandler application/x-httpd-php5s .php .js .css
规则停止工作
(我想出于网络托管中的安全原因),现在 JS 和除非用户刷新网页,否则 CSS 文件不会更新 F5
问题是,由于 CSS 或 JS 文件没有更新,用户不知道他们必须刷新页面才能看到的变化。
是否有另一种更简单的方法来执行相同的过程,但没有 .htaccess 中的 AddHandler 或解决此问题的方法。
To help a friend am translating his problem here:
Before I was including in the .htaccess AddHandler application/x-httpd-php5s .php .js .css
with the purpose that with the same PHP I could create the rules for Cache and Compression. What I did exactly was modify the auto_prepend_file in the php.ini file, pointing it to a PHP file and through there check the variable that is send by the browsers in the header $_SERVER["HTTP_IF_MODIFIED_SINCE"].
If the dates were different, I would answer with a header('HTTP/1.1 200 OK') and that would send the JS or CSS files compressed.
If the dates were the same, then I would send a header('HTTP/1.1 304 Not Modified') and the browser did not have to download the JS or CSS files in questioned.
For some reason, the AddHandler application/x-httpd-php5s .php .js .css
rule in the .htaccess stopped working
(I imagine for security reasons in the webhosting am in) and now the JS and CSS files are not been updated unless the user refreshes the webpage F5
The problem is that, since the CSS or JS files are not been updated the users do not know that they have to refresh the page to see the changes.
Is there another simpler way of doing the same procedure but without the AddHandler in .htaccess or a workaround for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论