在我的服务器上,我在端口 80 上运行 Varnish(缓存),Apache 在 8080 上。
当我设置如下标头时,Varnish 缓存非常好:
$this->getResponse()->setHeader('Expires', '', true);
$this->getResponse()->setHeader('Cache-Control', 'public', true);
$this->getResponse()->setHeader('Cache-Control', 'max-age=2592000');
$this->getResponse()->setHeader('Pragma', '', true);
但这意味着人们缓存我的网站,而不会在可用时检索新版本。
当我删除标题时,人们会在每个页面重新加载时检索一个新版本(因此 Varnish 永远不会缓存)。
我无法弄清楚这里出了什么问题。
我的理想情况是人们不会在客户端缓存 html,而是将其留给 Varnish。