• Login
  • Stats
  • Tools
  • Whois
  • Email Whois
  • Fingerprint
  • Logout
  • Contact
  • Lost Password
WebTracker.one
 
Login
Site Stats
Tools
Whois
Email Whois
Fingerprint
Logout
Contact
Lost Password
Please enable JavaScript to view this site.

Website Acceleration - Apache Caching

A website can be made faster by accelerating the delivery system. That can be accomplished by caching elements of the website in the server memory.

Enable the four following Apache modules and restart Apache:

sudo a2enmod cache
sudo a2enmod cache_disk
sudo a2enmod expires
sudo a2enmod headers

sudo systemctl restart apache2

You will then need to add directives to your apache2.conf file (for global) or virtual host file (for a specific website).

Here are the directives I added to my webtracker.one-le-ssl.conf host file - the code goes beneath the IfModule and VirtualHost starting lines:

Note: The following directives are based partially on trial and error. These settings tell the browser not do its own caching and to rely on server side caching. The settings still allow me to make html and style changes and for these changes to display immediately. CacheQuickHandler off CacheRoot '/var/cache/apache2/mod_cache_disk' CacheLock on CacheLockPath /tmp/mod_cache-lock CacheLockMaxAge 5 CacheDirLevels 4 CacheDirLength 5 CacheIgnoreHeaders Set-Cookie CacheIgnoreNoLastMod On CacheIgnoreCacheControl On CacheDisable /login.php #any file that you specifically do not want cached <Location /> CacheEnable disk CacheHeader on CacheDefaultExpire 600 CacheMaxExpire 86400 CacheLastModifiedFactor 0.5 ExpiresActive on ExpiresByType text/html 'access plus 0 seconds' ExpiresByType text/css 'access plus 0 seconds' ExpiresByType image/gif 'access plus 1 year' ExpiresByType image/jpg 'access plus 1 year' ExpiresByType image/jpeg 'access plus 1 year' ExpiresByType image/png 'access plus 1 year' ExpiresByType image/webp 'access plus 1 year' ExpiresByType text/javascript 'access plus 30 days' ExpiresByType application/javascript 'access plus 30 days' ExpiresByType application/x-javascript 'access plus 30 days' ExpiresByType video/mp4 'access plus 1 year' Header merge Cache-Control public FileETag All </Location>

If you want more information on what these settings mean, here are available resources:
ServerLab.ca
IBM
Digital Ocean

If you wish to enable logging, add the following line to your apache2.conf file or virtual host file:

CustomLog /var/log/apache2/cache.log cachelog

And add the following line to your apache2.conf file (you can modify the line as you wish):

LogFormat '%a %v:%p %t %r %{cache-status}e %>s ' cachelog

After this, restart Apache.

sudo systemctl restart apache2

You will then be able to see caching activity by entering the following command:

sudo tail -f /var/log/apache2/cache.log

     * posted by Robert on Fri, Sep 02, 2022



Website Acceleration - Apache Caching

Reply 1:

Apache's mod_cache can be enhanced by caching data in the random access memory (RAM). This is done through Memcached, which is already included in Ubuntu and other Debian systems. All you have to do is enable it. Here are the steps:

Start Memcached:

sudo systemctl start memcached

Enable Memcached:

sudo systemctl enable memcached

Check the status of Memcached:

sudo systemctl status memcached

     * posted by Robert on Wed, May 15, 2024


Return to Weblog Home



Site built and hosted by RJdesign.one