• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Apache 2.4 Disk Cache : How To Use And Why Not To Use

By Abhishek Ghosh October 17, 2017 5:51 pm Updated on October 12, 2018

Apache 2.4 Disk Cache : How To Use And Why Not To Use

Advertisement

When you are using Apache2 server, then you are well aware of the fact that Apache2 is intended to be powerful, enterprise grade web server. Apache 2.4 disk cache is powerful cache and is content aware. Many users while trying to use old directives face no caching – that is intended to escape errors on many servers which are not closely managed. As Apache 2.4 has undergone many changes like HTTP/2 Server Push, many old features with vulnerabilities needed to be escaped and pushed for the managed, well monitored servers. Here is how to use Apache2 disk cache and also our opinion why, when not to use.

 

Apache 2.4 Disk Cache : How To Use

 

This article is for those who have installed Apache2 in our described way on server running newer operating system like Ubuntu 16.04 LTS.

First enable module cache :

Advertisement

---

Vim
1
a2enmod cache

You will receive the message :

Vim
1
2
3
Enabling module cache.
To activate the new configuration, you need to run:
  systemctl restart apache2

Restart Apache :

Vim
1
systemctl restart apache2

Create a directory for Apache2 :

Vim
1
mkdir -p /var/apache-cache

Give proper ownership :

Vim
1
2
3
chown www-data /var/apache-cache
chgrp www-data /var/apache-cache
ls -al /var/apache-cache

Enable module cache_disk :

Vim
1
sudo a2enmod cache_disk

You’ll receive this message :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
Considering dependency cache for cache_disk:
Module cache already enabled
Enabling module cache_disk.
Enabling external service apache-htcacheclean
Synchronizing state of apache-htcacheclean.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable apache-htcacheclean
insserv: warning: current start runlevel(s) (empty) of script `apache-htcacheclean' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `apache-htcacheclean' overrides LSB defaults (0 1 6).
The service will be started on next reboot.
To activate the new configuration, you need to run:
  systemctl restart apache2
  systemctl start apache-htcacheclean

Run the needed commands to activate cache_disk :

Vim
1
2
systemctl restart apache2
systemctl start apache-htcacheclean

Change directory to /etc/apache2/sites-available :

Vim
1
2
cd /etc/apache2/sites-available
ls -al

Taking that your website is using HTTPS with Let’s Encrypt, your file for current vhost can be anything which you know, like :

Vim
1
2
000-default-le-ssl.conf
default-ssl.conf

Open the file, the files usually starts with :

Vim
1
2
3
4
<IfModule mod_ssl.c>
<VirtualHost *:443>
# The ServerName directive sets the request scheme, hostname and port that
...

Exactly like our guide on OSCP Stapling configuration on Apache2.4, you’ll add the directives after and before :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
CacheQuickHandler off
CacheLock on
CacheLockPath /var/apache-cache
CacheLockMaxAge 5
CacheIgnoreHeaders Set-Cookie
 
<Location />
    CacheEnable disk
    CacheHeader on
    CacheDefaultExpire 800
    CacheMaxExpire 64000
    CacheIgnoreNoLastMod On
    ExpiresActive on
    ExpiresDefault A300
</Location>

Save the file and run configuration test :

Vim
1
sudo apachectl configtest

Upon success, restart Apache :

Vim
1
sudo systemctl restart apache2

You’ll see files written at /var/apache-cache. htcacheclean is used to maintain a control over the size of the filesystem that disk_cache uses. Run man htcacheclean or search the web to use it from cron to flush cache on need.

Now for WordPress like CMS, the above configuration will seriously interfere and posts on frontend unlikely to open on click. First the above configuration needs some edit to escape caching like wp-admin or some files with form or special need :

Vim
1
2
3
CacheDisable /wp-admin
CacheDisable /wp-login.php
CacheDisable /wp-cron.php

You need to cache only posts, pages. We need to modify WordPress Permalink from .htaccess or whatever file you use :

Vim
1
2
3
4
5
6
# WordPress Permalink rewrites
RewriteBase /
RewriteRule ^index.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

It is more practical to cache selectively the areas you will likely to need least update :

Vim
1
2
3
4
5
6
7
8
9
# Cache the home page
<LocationMatch "^/$">
CacheEnable disk
</LocationMatch>
 
# Cache category pages
<Location /category>
CacheEnable disk
</Location>

 

Apache 2.4 Disk Cache : Why Not To Use

 

Apache-2.4-Disk-Cache-How-To-Use-And-Why-Not-To-Use

These modules are really for fully managed and 24 hours monitored servers. Bugs, security flaws of these modules are common and often need custom fix. Odd HTTP errors not uncommon which needs active monitoring of log files. Most of the users self manage servers. Number of ordinary users of these modules are less. These are better for static websites and really WordPress has lot of ways of caching including adding a reverse proxy server at front running Nginx. It is very difficult to flush the cache after publication of a post.

Tagged With windows set apache service cach size , apache2 cache_disk , apache server not using disk , apache root directory of the disk cache , apache mod_disk_cache NOT mod_mem_cache , apache disk cache , apache cache location windows , apache 2 4 doesn\t write cache , apache 2 4 caching , apache 2 4 cache videos

This Article Has Been Shared 698 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Apache 2.4 Disk Cache : How To Use And Why Not To Use

  • HTML5, WordPress and Cloud : What We Learnt From Redesign

    HTML5, WordPress and Cloud – with new redesign,not complete yet at the time of publishing this post we learnt important points with this old blog with 5K posts.

  • WordPress Persistent Object Cache, Fragment Cache Optimisation

    WordPress Persistent Object Cache, Fragment Cache Optimisation Can Improve Page Loading Time. You Can Setup Separate Cloud Server For Cache.

  • Apache Solr vs. Elasticsearch For WordPress Search

    Apache Solr vs. Elasticsearch For WordPress Search is a Complicated Topic as the Number of Plugin is a Matter Which We Need to Consider.

  • How to Include Jupyter Notebooks in WordPress Posts

    How to Include Jupyter Notebooks in WordPress Posts? There Are Several Ways. It Depends on What Exactly Your Blogs Are About.

  • Configure Apache Tika With WordPress to Search, Get Meta of PDF/Doc Files

    Apache Tika Can Be Combined With PHP. Here is How to Configure Apache Tika With WordPress to Search, Get Meta of PDF/Doc/Excel/Text and Other Type of Files.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • What is Voice User Interface (VUI) January 31, 2023
  • Proxy Server: Design Pattern in Programming January 30, 2023
  • Cyberpunk Aesthetics: What’s in it Special January 27, 2023
  • How to Do Electrical Layout Plan for Adding Smart Switches January 26, 2023
  • What is a Data Mesh? January 25, 2023

About This Article

Cite this article as: Abhishek Ghosh, "Apache 2.4 Disk Cache : How To Use And Why Not To Use," in The Customize Windows, October 17, 2017, February 1, 2023, https://thecustomizewindows.com/2017/10/apache-2-4-disk-cache-use-not-use/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT