Configuring Caching
mod_pagespeed requires publicly cacheable resources to provide maximum benefit. As discussed in the "Cache Extender" filter, the origin TTL specified in the Apache configuration file dictates how quickly changes made to the source can propagate to users' browser caches. However, using mod_pagespeed, resources referenced statically from HTML files will be served with a one-year cache lifetime, but with a URL that is versioned using a content hash.The cache settings suggested above for mod_pagespeed_example also serve as our recommended starting point for ensuring that your sites' content is cacheable, and thus rewritable by mod_pagespeed.
Configuring Server-Side Cache for mod_pagespeed
In order to rewrite resources, mod_pagespeed must cache them on the server. The output filter must be configured with paths where it can write cache files, and tuned to limit the amount of disk space consumed. The file-based cache has a built in LRU mechanism to remove old files, targeting a certain total disk space usage, and a certain interval for the cleanup process. It is also useful to have a small in-memory write-through LRU-cache that's kept in each Apache process. Keep in mind that in pre-fork mode, Apache spawns dozens of processes, so the total memory consumed (ModPagespeedLRUCacheKbPerProcess * num_processes) must fit into the capabilitiess of the HTTP server. The default values are, which perform reasonably well are:
ModPagespeedFileCacheSizeKb 102400
ModPagespeedFileCacheCleanIntervalMs 3600000
ModPagespeedLRUCacheKbPerProcess 1024
ModPagespeedLRUCacheByteLimit 16384mod_pagespeed requires a file-path for the cache. The user can use the following suggested setting:
ModPagespeedFileCachePath "/var/mod_pagespeed/cache/"mod_pagespeed also requires another file-path, although it's not currently used. It's reserved for future use as a shared database in a multi-server environment. The user can use the following suggested setting:
ModPagespeedGeneratedFilePrefix "/var/mod_pagespeed/files/"
Setting the URL fetcher timeout
When mod_pagespeed attempts to rewrite a resource for the firet time, it must fetch it via HTTP. The default timeout for fetches in 5 seconds. A directive can be applied to change the timeoutModPagespeedFetcherTimeoutMs timeout_value_in_millisecondsThese directives can not be used in
.htaccess files or <Directory> scopes.
No comments:
Post a Comment