wordpress mod_pagespeed 删除缓存?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13082948/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mod_pagespeed delete cache?
提问by Szed
We have a server (OVH - France), with Apache and mod_pagespeed. On this server, I have an installation of WordPress.
我们有一个服务器(OVH - 法国),带有 Apache 和mod_pagespeed。在这台服务器上,我安装了 WordPress。
I made a change in a Javascript file in my theme, but pagespeed don't understand there is a new file, and keeps loading the original javascript file. js/ui.js.pagespeed********
我在我的主题中对 Javascript 文件进行了更改,但 pagespeed 不知道有一个新文件,并不断加载原始 javascript 文件。 js/ui.js.pagespeed********
I made the change two weeks ago, rebooted the server this morning, and it is still loading the original Javascript file.
我两周前进行了更改,今天早上重新启动了服务器,它仍在加载原始 Javascript 文件。
How can I delete the pagespeed cache?
如何删除pagespeed缓存?
On my server, in /var/mod_pagespeedcache/http,3A/,2Fwww.myURL.fr/wp-content/themes/mytheme/js
, I see the ui.js.pagespeed.jm.************.js
.
在我的服务器上,在 中/var/mod_pagespeedcache/http,3A/,2Fwww.myURL.fr/wp-content/themes/mytheme/js
,我看到ui.js.pagespeed.jm.************.js
.
Could I just delete this file?
我可以删除这个文件吗?
回答by Saurabh Chandra Patel
Google's PageSpeed docs on Legacy Flushing Of Entire Cachesuggests this:
谷歌关于Legacy Flushing Of Entire Cache的 PageSpeed 文档表明了这一点:
sudo touch /var/cache/mod_pagespeed/cache.flush
回答by sligocki
From: https://developers.google.com/speed/docs/mod_pagespeed/faq#ignores-changes
来自:https: //developers.google.com/speed/docs/mod_pagespeed/faq#ignores-changes
There are two distinct cache-times at play when you use mod_pagespeed:
The origin TTL which mod_pagespeed uses to refresh its internal server-side cache.
The TTL with which mod_pagespeed serves rewritten resources to browsers. When mod_pagespeed first reads your reousrce file, it uses the origin TTL to figure out how often to re-examine the origin CSS file. Assume your origin TTL is 1 day. Once mod_pagespeed has that file in cache, it will not go back & re-check that file for a day. Changing the TTL after mod_pagespeed has put the resource in its cache will not help because mod_pagespeed is not going to reload the resource until the one in its cache expires, or you clear its cache.
We recommend an origin TTL of 10 minutes, which provides reasonable responsiveness when you update a file. If you try to make it much smaller, then your server will need to refresh it more frequently. This adds server load and reduces optimization.
To see changes to your files more quickly while developing, flush the cacheon your server(s).
If your environment allows you to enable ModPagespeedLoadFromFile, you can get the best of both worlds because mod_pagespeed can eliminate its internal server-side cache.
当您使用 mod_pagespeed 时,有两种不同的缓存时间在起作用:
mod_pagespeed 用于刷新其内部服务器端缓存的原始 TTL。
mod_pagespeed 为浏览器提供重写资源的 TTL。当 mod_pagespeed 第一次读取您的 reousrce 文件时,它使用源 TTL 来计算重新检查源 CSS 文件的频率。假设您的原始 TTL 为 1 天。一旦 mod_pagespeed 将该文件放入缓存中,它就不会返回并在一天内重新检查该文件。在 mod_pagespeed 将资源放入其缓存后更改 TTL 将无济于事,因为 mod_pagespeed 不会重新加载资源,直到其缓存中的资源过期,或者您清除其缓存。
我们建议源 TTL 为 10 分钟,这样可以在您更新文件时提供合理的响应。如果你试图让它更小,那么你的服务器将需要更频繁地刷新它。这会增加服务器负载并减少优化。
如果您的环境允许您启用 ModPagespeedLoadFromFile,您就可以两全其美,因为 mod_pagespeed 可以消除其内部服务器端缓存。
回答by L0j1k
Flushing the cache of a specific page in Pagespeed requires that the server support cache purging. In Apache, this means ModPagespeedEnableCachePurge on
in the site's configuration. In Nginx, you'll need pagespeed EnableCachePurge on;
instead. This setting allows you to send a specially-crafted HTTP request to force-purge a specific page in Pagespeed. For example with cURL:
在 Pagespeed 中刷新特定页面的缓存需要服务器支持缓存清除。在 Apache 中,这意味着ModPagespeedEnableCachePurge on
在站点的配置中。在 Nginx 中,您需要pagespeed EnableCachePurge on;
改为。此设置允许您发送特制的 HTTP 请求以强制清除 Pagespeed 中的特定页面。例如使用卷曲:
curl 'http://example.com/pagespeed_admin/cache?purge=path/file.ext'
curl 'http://example.com/pagespeed_admin/cache?purge=path/file.ext'
There is also another method for purging single pages in the cache (curl --request PURGE 'http://www.example.com/path/file.ext'
), however this requires an extra, optional config option in your site's config file (ModPagespeedPurgeMethod PURGE
for Apache and pagespeed PurgeMethod PURGE;
for Nginx).
还有另一种清除缓存中的单个页面的方法 ( curl --request PURGE 'http://www.example.com/path/file.ext'
),但是这需要您站点的配置文件(ModPagespeedPurgeMethod PURGE
对于 Apache 和pagespeed PurgeMethod PURGE;
Nginx)中有一个额外的可选配置选项。
For more information, please refer to the documentationdescribing this process for more detail.
有关更多信息,请参阅描述此过程的文档以获取更多详细信息。
回答by vsingh
sudo touch /var/cache/mod_pagespeed/cache.flush
Load the page again. You should see the changes
再次加载页面。你应该看到变化