简体   繁体   English

mod_pagespeed 删除缓存?

[英]Mod_pagespeed delete cache?

We have a server (OVH - France), with Apache and mod_pagespeed .我们有一个服务器(OVH - 法国),带有 Apache 和mod_pagespeed On this server, I have an installation of WordPress.在这台服务器上,我安装了 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.我在我的主题中对 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?我可以删除这个文件吗?

谷歌关于Legacy Flushing Of Entire Cache的 PageSpeed 文档表明了这一点:

sudo touch /var/cache/mod_pagespeed/cache.flush

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:当您使用 mod_pagespeed 时,有两种不同的缓存时间在起作用:

The origin TTL which mod_pagespeed uses to refresh its internal server-side cache. mod_pagespeed 用于刷新其内部服务器端缓存的原始 TTL。

The TTL with which mod_pagespeed serves rewritten resources to browsers. mod_pagespeed 为浏览器提供重写资源的 TTL。 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.当 mod_pagespeed 第一次读取您的 reousrce 文件时,它使用源 TTL 来计算重新检查源 CSS 文件的频率。 Assume your origin TTL is 1 day.假设您的原始 TTL 为 1 天。 Once mod_pagespeed has that file in cache, it will not go back & re-check that file for a day.一旦 mod_pagespeed 将该文件放入缓存中,它就不会返回并在一天内重新检查该文件。 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 .在 mod_pagespeed 将资源放入其缓存后更改 TTL 将无济于事,因为 mod_pagespeed 不会重新加载资源,直到其缓存中的资源过期,或者您清除其缓存

We recommend an origin TTL of 10 minutes, which provides reasonable responsiveness when you update a file.我们建议源 TTL 为 10 分钟,这样可以在您更新文件时提供合理的响应。 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 cache on 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.如果您的环境允许您启用ModPagespeedLoadFromFile ,您就可以两全其美,因为 mod_pagespeed 可以消除其内部服务器端缓存。

Flushing the cache of a specific page in Pagespeed requires that the server support cache purging.在 Pagespeed 中刷新特定页面的缓存需要服务器支持缓存清除。 In Apache, this means ModPagespeedEnableCachePurge on in the site's configuration.在 Apache 中,这意味着在站点配置中ModPagespeedEnableCachePurge onModPagespeedEnableCachePurge on In Nginx, you'll need pagespeed EnableCachePurge on;在 Nginx 中,您需要pagespeed EnableCachePurge on; instead.反而。 This setting allows you to send a specially-crafted HTTP request to force-purge a specific page in Pagespeed.此设置允许您发送特制的 HTTP 请求以强制清除 Pagespeed 中的特定页面。 For example with cURL:例如使用卷曲:

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' ),但这需要您站点配置中的额外可选配置选项文件(Apache 的ModPagespeedPurgeMethod PURGEpagespeed PurgeMethod PURGE; Nginx 的)。

For more information, please refer to the documentation describing this process for more detail.有关更多信息,请参阅描述此过程的文档以获取更多详细信息。

sudo touch /var/cache/mod_pagespeed/cache.flush

Load the page again.再次加载页面。 You should see the changes你应该看到变化

On bitnami AWS server (lightsail) use this commands:在 bitnami AWS 服务器 (lightsail) 上使用以下命令:

sudo touch /opt/bitnami/apache2/var/cache/mod_pagespeed/cache.flush

Restart Apache:重启阿帕奇:

sudo /opt/bitnami/ctlscript.sh restart apache

Here is the help page .这是帮助页面

刷新缓存 nginx 页面速度

sudo touch /var/cache/ngx_pagespeed/cache.flush

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM