安装程序
Debian GNU/Linux 7.6(wheezy)将完全访问Apache和virtual
宿主文件。
混凝土5 CMS:http://www.concrete5.org/
问题
我们的网站正在发送Pragma: no-cache
邮件头,这将阻止许多优化工作,包括CloudFlare服务:https://www.cloudflare.com/
不起作用的解决方案
在研究时,我们要么不了解答案,要么似乎是针对特定的用例(比如我们没有使用的Oracle或php框架),但我们确实尝试了以下方法:
一。通过站点的.htaccess
强制缓存:
<FilesMatch "\.(ico|jpeg|png|gif|js|css)$">
Header unset Cache-Control
Header unset Pragma
</FilesMatch>
2。通过Concrete5的header.php文件强制缓存
header("Cache-Control: max-age=2592000"); //30days (60sec * 60min * 24hours * 30days)
三。使用grep搜索
no-cache
的站点根目录 $ grep -r "no-cache" * .
backup/databasebackup.php:header('Cache-Control: no-cache, must-revalidate');
concrete/core/controllers/single_pages/login.php: header("Cache-Control: no-store, no-cache, must-revalidate");
concrete/core/controllers/single_pages/login.php: header("Pragma: no-cache");
concrete/js/tiny_mce/plugins/spellchecker/rpc.php:header("Cache-Control: no-store, no-cache, must-revalidate");
concrete/js/tiny_mce/plugins/spellchecker/rpc.php: header("Pragma: no-cache");
concrete/libraries/3rdparty/securimage/securimage.php: header('Cache-Control: no-store, no-cache, must-revalidate');
concrete/libraries/3rdparty/securimage/securimage.php: header("Cache-Control: no-store, no-cache, must-revalidate");
concrete/libraries/3rdparty/securimage/securimage.php: header("Pragma: no-cache");
但是,在查看Concrete5正在设置
no-cache
的文件/脚本(登录、数据库备份、文本编辑器配置等)之后,我们有点理解为什么-加上这些似乎是针对特定的文件,而不是整个站点对吗?四。创建一个空白的php文件,请求它并检查头
空白文件中有缓存,因此我们怀疑是php造成的-但不知道如何隔离原因抱歉。
问题
如何解决这个问题?
技能水平
我们做前端设计,并了解如何设置和服务一个CMS的基础知识,但没有太多的经验与服务器配置或故障排除缓存问题。
我们可以通过命令行访问服务器,并且几乎可以完全访问Debian、Apache和站点的安装。
任何帮助都将不胜感激。
干杯
本
最佳答案
更新
要在PHP脚本中添加max age:
header("Cache-Control: max-age=xxxx");
其中
xxxx
是要缓存的秒数,零表示没有缓存。或者
如果按内容类型(MIME类型)配置
header('Content-Type: text/html; charset=utf-8');
头集缓存控件“max age=0,无存储”
要按内容类型(MIME类型)配置缓存,请执行以下操作:
在htaccess ot httpd.conf中
ExpiresByType text/html "access plus 30 day"
ExpiresByType text/css "access plus 30 day"
ExpiresByType text/javascript "access plus 30 day"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
如果这些方法不起作用,则需要确保模块已加载。
您需要访问httpd.conf
LoadModule expires_module libexec/mod_expires.so
LoadModule headers_module libexec/mod_headers.so
AddModule mod_expires.c
AddModule mod_headers.c
...
AddModule mod_gzip.c
注意,在Apache/1.3x中,加载顺序很重要,mod_gzip必须在所有其他模块之后最后加载。
对于Apache/2.0:
LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
LoadModule deflate_module modules/mod_deflate.so
更新结束
您应该基于MIME类型和(或而不是)文件扩展名添加相同的缓存。
缓存应该是最长时间。
W3C说,max age优先于所有其他缓存头。
如果您没有得到“内部服务器错误500”,那么您已经做得很好了
在FireFox或Chrome中
右键单击页面
选择检查元素
转到“网络选项卡”
将类型从“All”更改为“HTML”
单击列表中的HTML页面
您应该能够确切地看到HTTP响应头中的内容。
火狐
铬
关于php - 如何在Debian上使用Concrete5对“编译指示:无缓存”进行故障排除?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30203788/