在 plesk 中设置 Cache-Control header 导致矛盾

Setting Cache-Control header in plesk results in contradiction

我需要设置 Cache-Control 以在应用中启用移动缓存。

问题是无论我在 .htaccess 中放入什么,响应 header 都没有改变。它保持

Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0

我尝试在 plesk 中禁用 nginx,结果如下:

Cache-Control:max-age=2628000, public
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0

我放在那里的 .htaccess 代码:

 Header set Cache-Control "max-age=2628000, public"

您有两个 "Cache-Control" header 回复:

Cache-Control:max-age=2628000, public
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0

这意味着您有 "Cache-Control" header 的第二个定义,它可以在全局 apache 配置中,在您域的 VirtualServer 中,在另一个 .htaccess 中。

/etc/httpd/ or /etc/apache2/ <-- for global configs
/var/www/vhosts/system/your-domain.tld/conf/ <-- for custom configs
/var/www/vhosts/your-domain.tld/ <-- for another .htaccess files

另外 back-end application(PHP) 和 front-end(JavaScript) 可以添加这个 header.

这里的问题是我使用的 CMS (Processwire) 自动将 Cache-Control 设置为无缓存。

我只是添加了

header_remove("Cache-Control");

在我希望 Cache-Control 完全遵循我的 .htaccess 的页面上