我配置了 pagespeed 来缓存 js 和 css 文件,以提高服务器性能。但有时服务器负载和性能滞后非常明显。因此想调整 pagespeed。我将 pagespeed 的ModPagespeedFileCacheSizeKb
配置从 100KB 增加到 512KB。这样做之后,清理频率降低了(每 5 小时一次)。以下是 pagespeed 日志:
[Wed Apr 30 16:06:37 2014] [info] [mod_pagespeed 1.3.25.4-2941 @25845] File cache size is 526295040 and contains 62559 inodes; no cleanup needed.
[Wed Apr 30 17:11:56 2014] [info] [mod_pagespeed 1.3.25.4-2941 @4420] File cache size is 553115648 and contains 65117 inodes; beginning cleanup.
[Wed Apr 30 17:12:02 2014] [info] [mod_pagespeed 1.3.25.4-2941 @4420] File cache cleanup complete; freed 150609920 bytes
[Wed Apr 30 18:12:19 2014] [info] [mod_pagespeed 1.3.25.4-2941 @14154] File cache size is 448905216 and contains 54087 inodes; no cleanup needed.
我的问题是如何测量正确的缓存大小,以便不需要从 pagespeed 进行清理?
为什么每次清理调用时缓存和 inode 大小都会增加?这意味着什么?
答案1
查看 pagespeed.conf 文件,其中有一些内置的控制/监控面板,您可以启用和访问。它为您提供使用情况统计信息,您会发现这些信息对于调整这些参数很有用。
参见第 286 行左右的内容;
# This page lets you view statistics about the mod_pagespeed module.
<Location /mod_pagespeed_statistics>
Order allow,deny
# You may insert other "Allow from" lines to add hosts you want to
# allow to look at generated statistics. Another possibility is
# to comment out the "Order" and "Allow" options from the config
# file, to allow any client that can reach your server to examine
# statistics. This might be appropriate in an experimental setup or
# if the Apache server is protected by a reverse proxy that will
# filter URLs in some fashion.
Allow from all
#Allow from 127.0.0.1
SetHandler mod_pagespeed_statistics
</Location>
# Enable logging of mod_pagespeed statistics, needed for the console.
ModPagespeedStatisticsLogging off
<Location /pagespeed_console>
Order allow,deny
Allow from all
#Allow from 127.0.0.1
SetHandler pagespeed_console
</Location>
此外,如果您正在调整服务器性能,使用基于文件的缓存会很慢,因为文件系统是迄今为止最大的性能瓶颈。相反,如果可以,请安装 Memcached 服务器,因为 Pagespeed 已内置对它的支持,并将为您带来即时且相当大的性能提升。
ModPagespeedMemcachedServers localhost:11211