Enabling server caching on Apache

In this post we discuss the usage of mod_cache or mod_expires to enable server caching on Apache ...

Home My Blog Other Blog Posts → Enabling server caching on Apache
enabling server caching on apache


In a previous post I shared details on how to enable browser caching and since then I got a question on how to do the same, but on the server in order to save system resources.
So I decided to write the current post and give an example on how to enable server caching on Apache using the Apache native modules mod_cache or mod_expires.

To do that with mod_cache and considering the same example - to make the cache expire in 4 hours, you can edit the Apache configuration file (it's usually /etc/apache2/apache2.conf or /etc/httpd/httpd.conf) and add there -

<IfModule mod_cache.c>
CacheDefaultExpire 14400
CacheEnable disk /
CacheHeader on
</IfModule>

Another possibility is to use mod_expires - for example to hide the "output" just from php files for 4 hours -

<FilesMatch ".php$">
ExpiresActive On
ExpiresDefault "access plus 4 hours"
</FilesMatch>




See More Blog PostsHire Me For A Project or Consultation






 
Connect with meLinkedIn ProfileFacebook Profile


2024 © SofiaCoder.com
×

My BlogProgramming Web Design SEO Other Home PageSofia Coder LinkedIn ProfileSofia Coder Facebook Profile