如何在 Debian 上使用 Concrete5 解决 "Pragma: no-cache" 问题?
How to troubleshoot "Pragma: no-cache" with Concrete5 on Debain?
设置
- Debian GNU/Linux 7.6 (wheezy) 将完全访问 Apache 和虚拟
主机文件。
- Concrete5 内容管理系统:http://www.concrete5.org/
问题
我们的网站将在 header 秒内发送 Pragma: no-cache
,这会阻止一些优化工作 - 包括 CloudFlare 服务:https://www.cloudflare.com/
无效的解决方案
在研究时,我们要么不理解答案,要么它们似乎是针对特定用例的(例如 Oracle 或我们未使用的 php 框架),但我们确实尝试了以下方法:
1.通过站点的 .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)
3。使用 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");
但是在查看 files/scripts Concrete5 正在设置 no-cache
(登录、数据库备份、文本编辑器配置等)之后,我们有点理解为什么 - 而且这些似乎是针对特定文件的,不是整个网站吗?
4。制作一个空白 php 文件,请求它并检查 header
空白文件是在启用缓存的情况下提供的,因此我们怀疑 php 是罪魁祸首 - 但不知道如何找出原因,抱歉。
问题
我们如何排查和解决此问题?
技能水平
我们 front-end 设计并了解有关如何设置和提供 CMS 的基础知识,但在服务器配置或缓存问题故障排除方面没有太多经验。
我们可以通过命令行访问服务器,并且几乎可以完全访问 Debian、Apache 和站点的安装。
如有任何帮助,我们将不胜感激。
干杯
本
更新
要在 PHP 脚本中添加 max-age:
header("Cache-Control: max-age=xxxx");
其中 xxxx
是要缓存的秒数,零表示没有缓存。
或
如果您配置 Content-Type(MIME 类型)
header('Content-Type: text/html; charset=utf-8');
Header 设置 Cache-Control "max-age=0, no-store"
通过Content-Type(MIME 类型)配置缓存:
在 .htaccess 中 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 类型以及(或而不是)文件扩展名添加相同的缓存。
缓存应该是max-age。
W3C 表示 max-age 优先于所有其他缓存 headers。
如果您没有得到 "Internal Server Error 500"
,那么您已经做得很好了
在 FireFox 或 Chrome
- 右键单击页面
- Select 检查元素
- 前往 "Network Tab"
- 将类型从 "All" 更改为 "HTML"
- 单击列表中的 HTML 页面
您应该能够准确地看到 HTTP 响应中的内容 Header。
FireFox
Chrome
终于查明了,页面上的一些 Concrete5 块正在阻止页面被缓存。
如果我们打开 "Force full page caching" 然后我们会看到一些奇怪的行为,因为缓存冻结了功能,所以我们不得不将其关闭。
基本上,由于页面上的块功能,我们无法完全缓存站点。我们只能使用APC缓存。
设置
- Debian GNU/Linux 7.6 (wheezy) 将完全访问 Apache 和虚拟 主机文件。
- Concrete5 内容管理系统:http://www.concrete5.org/
问题
我们的网站将在 header 秒内发送 Pragma: no-cache
,这会阻止一些优化工作 - 包括 CloudFlare 服务:https://www.cloudflare.com/
无效的解决方案
在研究时,我们要么不理解答案,要么它们似乎是针对特定用例的(例如 Oracle 或我们未使用的 php 框架),但我们确实尝试了以下方法:
1.通过站点的 .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)
3。使用 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");
但是在查看 files/scripts Concrete5 正在设置 no-cache
(登录、数据库备份、文本编辑器配置等)之后,我们有点理解为什么 - 而且这些似乎是针对特定文件的,不是整个网站吗?
4。制作一个空白 php 文件,请求它并检查 header
空白文件是在启用缓存的情况下提供的,因此我们怀疑 php 是罪魁祸首 - 但不知道如何找出原因,抱歉。
问题
我们如何排查和解决此问题?
技能水平
我们 front-end 设计并了解有关如何设置和提供 CMS 的基础知识,但在服务器配置或缓存问题故障排除方面没有太多经验。
我们可以通过命令行访问服务器,并且几乎可以完全访问 Debian、Apache 和站点的安装。
如有任何帮助,我们将不胜感激。
干杯
本
更新
要在 PHP 脚本中添加 max-age:
header("Cache-Control: max-age=xxxx");
其中 xxxx
是要缓存的秒数,零表示没有缓存。
或
如果您配置 Content-Type(MIME 类型)
header('Content-Type: text/html; charset=utf-8');
Header 设置 Cache-Control "max-age=0, no-store"
通过Content-Type(MIME 类型)配置缓存:
在 .htaccess 中 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 类型以及(或而不是)文件扩展名添加相同的缓存。
缓存应该是max-age。
W3C 表示 max-age 优先于所有其他缓存 headers。
如果您没有得到 "Internal Server Error 500"
,那么您已经做得很好了在 FireFox 或 Chrome
- 右键单击页面
- Select 检查元素
- 前往 "Network Tab"
- 将类型从 "All" 更改为 "HTML"
- 单击列表中的 HTML 页面
您应该能够准确地看到 HTTP 响应中的内容 Header。
FireFox
Chrome
终于查明了,页面上的一些 Concrete5 块正在阻止页面被缓存。
如果我们打开 "Force full page caching" 然后我们会看到一些奇怪的行为,因为缓存冻结了功能,所以我们不得不将其关闭。
基本上,由于页面上的块功能,我们无法完全缓存站点。我们只能使用APC缓存。