mod_cache not creating cache files?
Hello,
I'm trying to get mod_cache to work. I believe everything needed is installed through EasyApache4 (mod_cache and mod_cache_disk). I added a configuration to the pre_main_global include (see below) and apache restarts successfully with no errors but no cache files are being put into /var/cache/apache2/mod_cache_disk folder.
I've read the apache docs and numerous threads but can't seem to find a reason why cache files aren't being generated.
Here's what I added to the apache pre_main_global include:
If I enable the LoadModule lines, I get an error that the modules are already loaded when apache is restarted through the command line (service httpd restart). The mod_cache_disk folder is owned by nobody with full 777 permissions (777 is for testing, just to see if folder permissions were an issue). The server and site appear to be healthy just not seeing any cache files being generated (this is being tested on a Wordpress installation, the only domain on the server). Any insights would be appreciated.
# mod_cache code
#Following line not needed
#LoadModule3 cache_module modules/mod_cache.so
CacheQuickHandler off
CacheIgnoreNoLastMod On
CacheDefaultExpire 7200
CacheIgnoreCacheControl Off
CacheLastModifiedFactor 0.5
CacheIgnoreHeaders Set-Cookie Cookie
CacheHeader on
CacheLock on
CacheDisable /wp-admin
CacheDisable /wp-login.php
CacheDisable /wp-cron.php
SetOutputFilter CACHE
AddOutputFilterByType DEFLATE text/html text/plain text/css application/javascript application/rss+xml text/xml image/svg+xml
#Following line not needed
#LoadModule cache_disk_module modules/mod_cache_disk.so
CacheRoot /var/cache/apache2/mod_cache_disk
CacheEnable disk /
CacheDirLevels 2
CacheDirLength 1
CacheMaxFileSize 2000000
If I enable the LoadModule lines, I get an error that the modules are already loaded when apache is restarted through the command line (service httpd restart). The mod_cache_disk folder is owned by nobody with full 777 permissions (777 is for testing, just to see if folder permissions were an issue). The server and site appear to be healthy just not seeing any cache files being generated (this is being tested on a Wordpress installation, the only domain on the server). Any insights would be appreciated.
-
Hello @User8472, It looks like the issue might relate to the custom entry you are using under the "Pre Main Include" section. Here are the steps I took when testing with a standard configuration: 1. Install the required RPMs: yum install ea-apache24-mod_cache ea-apache24-mod_cache_disk
2. Create the cache storage directory:mkdir /var/cache/apache2/mod_cache/ chmod 0700 /var/cache/apache2/mod_cache chown nobody.nobody /var/cache/apache2/mod_cache/
3. Add the following entry to the "Pre Main Include" section in "WHM >> Apache Configuration >> Include Editor":CacheQuickHandler Off # Must be writable by apache 700 nobody:nobody CacheRoot /var/cache/apache2/mod_cache/ CacheEnable disk / CacheDirLevels 2 CacheDirLength 1 # X-Cache: [HIT|MISS] # CacheHeader on
4. Create /home/username/public_html/cache.php with the following contents:
5. Open $domain.tld/cache.php in a web browser. 6. Confirmed the cache files were generated in in the /var/cache/apache2/mod_cache/ directory:# pwd /var/cache/apache2/mod_cache/Q/Y # ls -al total 4 drwx------ 3 nobody nobody 81 Apr 25 09:46 . drwx------ 3 nobody nobody 15 Apr 25 09:46 .. -rw------- 1 nobody nobody 31 Apr 25 09:46 ye5IIyK6mE2K1mVMw7kw.header drwx------ 3 nobody nobody 15 Apr 25 09:46 ye5IIyK6mE2K1mVMw7kw.header.vary
Thank you.1 -
Thanks for the reply. It turns out that the CacheLock on in my original example was preventing the cache files from being created. Just commenting out that line enabled the cache files to be generated - not sure why though, it's a valid directive according to the apache documentation. Unfortunately, both my example and the example you provided produce unexpected results on the Wordpress site. Seemingly random files are served up using either configuration (the homepage seems fine, but further navigation produces unexpected content). But that's a separate issue. Also a quick question regarding your example. Shouldn't the CacheQuickHandler off be in a separate section as below? CacheQuickHandler off
Or am I misunderstanding how the cache directives are handled? Can directives from the cache_module be included in the cache_disk_module section? Apache doesn't complain either way. Thanks again for your help!0 -
Also a quick question regarding your example. Shouldn't the CacheQuickHandler off be in a separate section as below?
Hello, Yes, it's a directive of cache_module so it's generally better if it's part of the "" statement. That said, it should still work in either case in this instance because both of those Apache modules are enabled on the system. Any valid configuration value added to IfModule statements should work as long as that particular Apache module is enabled, even if it's not a directive of that particular module. This is documented in more detail at:0 -
Unfortunately, both my example and the example you provided produce unexpected results on the Wordpress site. Seemingly random files are served up using either configuration (the homepage seems fine, but further navigation produces unexpected content). But that's a separate issue.
I am getting this now. How did you solve this?0
Please sign in to leave a comment.
Comments
5 comments