Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

Enable the static cache

Step by step - generate static copies of public pages that the web server sends without starting PHP, check the result, switch StaticCache on, and keep it fresh, for sites that must stay fast under heavy public demand.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/government/tasks/operations/enable-the-static-cache.md

On this page

Enable the static cache

This task is for administrators of public sites that must cope with sudden demand (an announcement, an emergency). The static cache stores public pages as plain files that the web server sends without starting Exponential. It is off in a new installation (Operating a site, section 4).

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.

Contents

  1. Before you start
  2. Steps
  3. Check it worked
  4. Pitfalls
  5. Related pages

Before you start

  • Only siteaccesses that need no login are offered, because their pages are the same for everybody.
  • The web server rules of your installation that serve the static files are active (Apache with the shipped .htaccess); under Velocity the response cache is the usual alternative (Velocity response cache and HTTP cache).
  • A change approved for a settings change.

Steps

  1. See what it would do:

    php bin/php/cache.php static status --allow-root-user
  2. Generate pages of one site, limited first so you see it work:

    php bin/php/makestaticcache.php --site=site --max-pages=500 --max-depth=6 --allow-root-user

    Omit --site for every public siteaccess. In the browser: Setup > Cache management, section Static content cache, with a Stop button.

  3. Switch it on in settings/override/site.ini.append.php:

    [ContentSettings]
    StaticCache=enabled
  4. php bin/php/ezcache.php --clear-tag=ini --allow-root-user, then reload or deploy.

Check it worked

  • php bin/php/cache.php static status --allow-root-user counts the files per site in var/site/static.
  • Publish a change and check the page updates (publishing clears its static pages).

Pitfalls

  • Pages that show something personal (a signed-in user's name, a form with a token) must not be static.
  • Remove the files with php bin/php/cache.php static clear --allow-root-user when you switch it off again.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x