Velocity's response cache keeps rendered public pages and answers repeat requests inside the server process, before a worker is chosen, so a hit costs no worker at all. It behaves like a small reverse proxy: conditional requests (304), ETag, Age, stale-while-revalidate, negative caching, compressed storage, and invalidation by one touched file. A busy page never sends every visitor to PHP at once, because one request renews an expired page while the others are answered from the old copy.
Switch it on
The cache is off until a setting says enabled: true. In a site file, or a module such as mods-available/cache.conf:
{ "Q": { "web": { "cache": {
"enabled": true,
"dir": "/var/cache/qbix/example.com"
} } } }
With a configuration tree, qbixctl enmod cache turns it on at the next restart and qbixctl dismod cache turns it off. Then let the application say how long a page may live, with Cache-Control: public, max-age=300 for example, and restart or reload the server. Check by requesting the same public page twice: the second answer carries X-Cache: HIT and an Age header.
What is kept
- Only GET requests, never for the server's own paths (/Q/... and /.well-known/...).
- Status 200, or 404 and 410 when negativeTtl is set.
- Requests without an Authorization header and without any of the skip cookies.
- Responses that set no cookie and do not say no-store or private.
The lifetime is s-maxage, else max-age, else defaultTtl (0 by default, which stores nothing). A visitor's own Cache-Control: no-cache does not bypass the cache, so pressing reload cannot make the server render every page again.
Note: Set Q.web.cache.skip.cookies to your application's session cookie (the default is PHPSESSID and Q_sid). If it does not name it, a signed-in visitor can be served someone else's page; if it names a cookie every visitor carries, everyone bypasses the cache.
After a deploy
touch /var/cache/qbix/example.com/.generation qbixconsole cache:clear
Only the marker file's modification time counts: every entry stored at or before it is treated as a miss. Every worker and every server sharing the file sees it within a second. In Exponential, exp:velocity cache clear does the same, and exp:velocity deploy calls it last.
In Exponential
Exponential sets the cache through velocity.ini [CacheSettings]; DefaultTtl is 30 seconds. Pages whose templates name an expiry with cache_until carry a lifetime no longer than the time left, so the cache never keeps them past it.