You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This design eliminates per-request regex compilation in `.htaccess`, resulting in significantly faster cache delivery. The module is fully compatible with AccelerateWP's cache directory layout and can be used by any caching plugin that follows similar conventions.
1293
1293
1294
-
AccelerateWP uses this module to serve the correct static page without invoking PHP or writing complex RewriteRule-based configurations. This document summarizes the module's directives and describes how any page cache plugin can integrate with the same capabilities.
1294
+
AccelerateWP uses this module to serve the correct static page without invoking PHP or writing complex RewriteRule-based configurations. This document summarizes the module's directives and describes how any page cache plugin can integrate with the same capabilities.
1295
+
1296
+
The module includes two independent subsystems: **cache serving** (serves pre-generated static HTML files, bypassing PHP) and **HTCache** (caches parsed `.htaccess` files in shared memory, eliminating per-request disk I/O). Both are included in the same `ea-apache24-mod_maxcache` package and can be enabled independently.
1295
1297
1296
1298
:::warning Note:
1297
1299
MAx Cache is currently supported on cPanel control panels only.
@@ -1302,12 +1304,20 @@ MAx Cache is currently supported on cPanel control panels only.
| `libmaxcache` | Shared C library for device detection, WebP, cookie/QS handling |
1318
+
1319
+
After installation, the HTCache subsystem is enabled by default (`MaxCacheHTCache On`) and the `maxcache-htcache-watchd` daemon is automatically started and enabled on boot.
1320
+
1311
1321
### MAx Cache Activation Guide
1312
1322
1313
1323
Use the following commands to manage MAx Cache on your server via the cloudlinux-awp-admin tool.
@@ -1888,6 +1898,219 @@ MAx Cache will not work in AccelerateWP when:
1888
1898
* Using the AccelerateWP PHP filter to replace dots with underscores.
1889
1899
* Using the AccelerateWP PHP filter forces the full path to cache files instead of using DOCUMENT_ROOT.
1890
1900
1901
+
### HTCache (.htaccess caching)
1902
+
1903
+
HTCache is the second subsystem of `mod_maxcache`. It caches parsed `.htaccess` files in shared memory, so Apache does not re-read and re-parse them from disk on every request. On shared-hosting servers with thousands of sites, this eliminates thousands of `stat()` and `open()` syscalls per second.
1904
+
1905
+
HTCache benefits **all** `.htaccess`-heavy sites regardless of whether MAx Cache page caching is enabled.
1906
+
1907
+
#### How it works
1908
+
1909
+
By default, Apache re-reads and re-parses `.htaccess` files from disk on every request. On shared-hosting servers with thousands of sites, this creates significant disk I/O overhead. HTCache parses each `.htaccess` once (on first request) and stores the result in shared memory so all Apache workers can reuse it without touching the disk again. The cache populates lazily as traffic arrives.
1910
+
1911
+
#### Change detection
1912
+
1913
+
HTCache detects `.htaccess` changes through two mechanisms:
1914
+
1915
+
| Mode | Detection latency | When active |
1916
+
| --- | --- | --- |
1917
+
| **watchd (real-time)** | Sub-second | When `maxcache-htcache-watchd` service is running |
1918
+
| **Polling (fallback)** | Up to `MaxCacheHTCacheRevalidateInterval` seconds (default 60) | Always active as a safety net |
1919
+
1920
+
When the `maxcache-htcache-watchd` daemon is running, it monitors the filesystem and signals Apache through shared memory whenever a `.htaccess` file is created, modified, or deleted.
1921
+
1922
+
:::warning CloudLinux 7/8 limitations
1923
+
On CloudLinux 7 and 8, the kernel's `fanotify` interface only supports file write events. This means the watchd daemon detects `.htaccess` **modifications** instantly, but **deletes**, **renames**, and **moves** are not detected in real time — they rely on the polling fallback (`MaxCacheHTCacheRevalidateInterval`, default 60 seconds). If you need faster detection of these operations on CL7/CL8, lower the revalidation interval (e.g. `MaxCacheHTCacheRevalidateInterval 10`).
1924
+
1925
+
On CloudLinux 9+ (kernel 5.14+), all change types — including deletes, renames, and moves — are detected in real time.
1926
+
:::
1927
+
1928
+
#### Configuration directives
1929
+
1930
+
All HTCache directives go inside `<IfModule mod_maxcache.c>` in the Apache configuration. HTCache is configured in `/etc/apache2/conf.d/maxcache_htcache.conf`.
1931
+
1932
+
#### MaxCacheHTCache
1933
+
1934
+
* **Syntax**: `MaxCacheHTCache On|Off`
1935
+
* **Default**: On (in shipped config)
1936
+
* **Context**: server config, virtual host
1937
+
* **Description**: Master enable/disable switch for the HTCache subsystem.
* **Description**: Polling interval for `mtime` checks when the watchd daemon is not running or for event types not detected by `fanotify` on the current platform. Lower values mean faster detection of changes via polling; higher values reduce `stat()` syscalls.
1946
+
1947
+
#### MaxCacheHTCacheEntries
1948
+
1949
+
* **Syntax**: `MaxCacheHTCacheEntries <count>`
1950
+
* **Default**: 50000
1951
+
* **Range**: 10–500000
1952
+
* **Context**: server config, virtual host
1953
+
* **Description**: Maximum number of cached `.htaccess` entries in shared memory. When this limit is reached, new directories fall back to Apache's standard processing.
1954
+
1955
+
#### MaxCacheHTCacheMemorySize
1956
+
1957
+
* **Syntax**: `MaxCacheHTCacheMemorySize <MB>`
1958
+
* **Default**: auto (derived from `MaxCacheHTCacheEntries`)
1959
+
* **Range**: 1–4096
1960
+
* **Context**: server config, virtual host
1961
+
* **Description**: Shared memory arena size in megabytes. Normally sized automatically — only set this if you see `htcache: arena memory exhausted` in the error log.
* **Description**: Exclude directory trees from HTCache. The path is matched as a prefix.
1969
+
* **Example**:
1970
+
```
1971
+
MaxCacheHTCacheExclude /home/staging /tmp
1972
+
```
1973
+
1974
+
#### MaxCacheHTCacheMaxFileSize
1975
+
1976
+
* **Syntax**: `MaxCacheHTCacheMaxFileSize <KB>`
1977
+
* **Default**: 256
1978
+
* **Range**: 0–10240
1979
+
* **Context**: server config, virtual host
1980
+
* **Description**: Maximum `.htaccess` file size (in KB) that HTCache will process. Files exceeding this limit are skipped and served via Apache's standard processing. Set to `0` for unlimited.
* **Description**: Maximum cached entries under a single document root. Prevents one user from monopolizing the shared cache on multi-tenant servers. Set to `0` for unlimited (the global `MaxCacheHTCacheEntries` limit still applies).
1989
+
1990
+
#### Configuration examples
1991
+
1992
+
##### Minimal setup
1993
+
1994
+
```
1995
+
MaxCacheHTCache On
1996
+
```
1997
+
1998
+
Enables HTCache globally with default settings (50,000 max entries, 60-second revalidation).
| Log: `htcache: entry limit reached (50000/50000), skipping /path` | Cache is full — increase `MaxCacheHTCacheEntries` | Remaining directories use standard Apache processing |
2109
+
| Log: `htcache: per-docroot entry limit reached (256/256) for /home/user` | Single user filled their quota — increase `MaxCacheHTCacheMaxEntriesPerDocroot` | Other users are not affected |
2110
+
| Log: `htcache: arena memory exhausted (400MB/400MB)` | Shared memory arena is full — increase `MaxCacheHTCacheMemorySize` | Restart Apache after changing |
2111
+
2112
+
If changes must take effect immediately, restart Apache: `systemctl restart httpd`.
0 commit comments