Static cache defaults
Read this page if you use, or plan to use, the static cache (settings/staticcache.ini,
bin/php/makestaticcache.php). Before this change the shipped settings generated nothing on a stock installation.
The new defaults work out of the box, which means an existing override may now behave differently.
Warning
.htaccess slows down every request. When .htaccess files are enabled (AllowOverride anything but None), let alone
used, Apache looks for them and reads and evaluates them on every request, in every directory of the path, and
page loading times go up drastically (measured). The only real fix is to switch the feature off for
the virtual host: AllowOverride None in the HTTPS virtual host, and the rules in the virtual host's own
configuration as mod_rewrite rules. That is far faster in production speed tests and well worth the time it takes
to optimize a production configuration. Switch over right away: copy the rules of the
example HTTPS virtual host into your virtual host (with the static cache, also
staticcache_offload.conf), set AllowOverride None, run apachectl configtest, reload Apache and
test the site. The same rules for other servers: nginx, LiteSpeed,
Caddy, IIS, Velocity (built in); where virtual host rules go in a control
panel: Plesk, cPanel, DirectAdmin, ISPConfig.
On LiteSpeed or OpenLiteSpeed, the server's own page cache can also answer anonymous visitors and crawlers without PHP: Page caching with LiteSpeed and OpenLiteSpeed.
In short
| What changed | Six [CacheSettings] defaults in settings/staticcache.ini; the files now go to var/<site>/static. |
| Who is affected | Installations that override StaticStorageDir, serve static files from the web server, or relied on the old CachedURLArray[]. |
| How to check | grep -v '^#' settings/staticcache.ini | grep -v '^$' |
| How to fix | Follow the three steps under "How to fix". |
What changed
Before, HostName=localhost sent every fetch to a host that is not your site, and the failure was silent. Pages
were written to ./static in the installation root, where no cache tool looked.
File settings/staticcache.ini, block [CacheSettings], scope: installation.
| Key | Before | Now |
|---|---|---|
HostName | localhost | empty |
SourceProtocol | did not exist | http |
StaticStorageDir | static, meaning ./static in the root | static, meaning var/<site>/static |
MaxCacheDepth | 3 | 12 |
CachedURLArray[] | /, /news*, /weblog* | /, /* |
CachedSiteAccesses[] | empty, meaning nothing | empty, meaning every public siteaccess |
How to check
grep -v '^#' settings/staticcache.ini | grep -v '^$'
php bin/php/makestaticcache.php --help --allow-root-userThe first command prints the shipped defaults from the table above. The second lists the generator options.
How to fix
- You override
StaticStorageDir=staticand have files in./static. Either keep that directory by settingStaticStorageDir=/full/path/to/static(an absolute path is used as given), or generate the cache again and delete the old directory yourself. - You serve the files from the web server. Switch to
.htaccess_root_static(or the rules indoc/eng-us/examples/staticcache_offload.conf) and checkEZ_VAR_SITE..htaccess_rootis the plain rules again and does not serve static files. - You relied on
CachedURLArray[]listing only/news*and/weblog*. Put those lines back in your override. The new default caches the whole site, limited byMaxCacheDepth.