【问题标题】:How to disable cache of Apache?如何禁用Apache的缓存?
【发布时间】:2014-05-18 11:43:49
【问题描述】:

我只将 index.html 放在 /var/www/html 中。 我更改 index.html 的内容并重新加载后页面没有更新。

我已经在 httpd.conf 中禁用了 cache_module,如下所示。

# LoadModule cache_module modules/mod_cache.so
# LoadModule disk_cache_module modules/mod_disk_cache.so

【问题讨论】:

  • httpd.conf 在哪里?我在 Ubuntu 上的 /etc/var 的任何地方都找不到它。

标签: apache caching


【解决方案1】:

如果您使用的是 htaccess,那么您可以这样做

#Initialize mod_rewrite
RewriteEngine On
<FilesMatch "\.(html|htm|js|css)$">
  FileETag None
  <IfModule mod_headers.c>
    Header unset ETag
    Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires "Wed, 12 Jan 1980 05:00:00 GMT"
  </IfModule>
</FilesMatch>

【讨论】:

  • 谢谢!但是我把这个设置放在哪里?我把它放在 httpd.conf 的末尾,没有任何改变..
  • 在根目录下创建一个 .htaccess 文件,您已将文件上传到服务器并将上述行放入 .htaccess 文件中
  • 我这样做了,但结果没有改变。我也重启了 apache。
  • 检查您是否在托管公司的服务器中启用了 mod_rewrite。还要检查我在上面编辑了答案
  • .htaccess 对我不起作用。另外,我的apache2.conf 文件不包含EnableSendfile on,但我添加了EnableSendfile off,它不起作用,它仍在缓存中。
猜你喜欢
  • 2012-06-06
  • 2012-09-22
  • 2011-03-11
  • 2018-10-05
  • 2020-10-28
  • 2011-02-20
  • 2012-04-29
  • 2013-09-14
  • 2012-04-15
相关资源
最近更新 更多