Cobra Forum

Plesk Panel => Webserver => Topic started by: Suhitha on Dec 17, 2025, 07:13 AM

Title: How to enable leverage browser caching for Apache in Plesk
Post by: Suhitha on Dec 17, 2025, 07:13 AM
Applicable to:


Question

How to enable leverage browser caching in Plesk?


Answer

                                For particular subscription

1.Enable mod_expires: Plesk > Tools & Settings > Apache Web Server, tick expires > OK

2.Go to Subscriptions > example.com > Apache & nginx Settings, add below to Additional directives for HTTP and Additional directives for HTTPS sections:

<IfModule mod_expires.c>
ExpiresActive On
FileETag None
ExpiresDefault "access plus 14 days"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType text/css "now plus 1 month"
ExpiresByType image/ico "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType text/html "access plus 1 days"
</IfModule>


                                            For the whole server

First of all, connect to the server using SSH.

For RHEL-based operating systems (CentOS, RHEL, CloudLinux, Virtuozzo Linux 7)

1.Comment the line LoadModule expires_module modules/mod_expires.so in the file /etc/httpd/conf.modules.d/00-base.conf.

2.Create the configuration file /etc/httpd/conf.d/expires.conf:

# vi /etc/httpd/conf.d/expires.conf

3.Insert the following content in it:

LoadModule expires_module modules/mod_expires.so
ExpiresActive on
ExpiresDefault "access plus 14 days"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType text/css "now plus 1 month"
ExpiresByType image/ico "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType text/html "access plus 1 days"

4.Add the following line to the file /etc/httpd/conf/httpd.conf:

FileETag None
5.Apply the configuration changes:

# service httpd reload

6.Validate the Apache configuration:

# httpd -t
Syntax OK

7.Check that the module is loaded:

# httpd -M | grep expires
expires_module (shared)

For Debian and Ubuntu

1.Add the following content into the file /etc/apache2/mods-available/expires.load:

ExpiresActive on
ExpiresDefault "access plus 14 days"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType text/css "now plus 1 month"
ExpiresByType image/ico "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType text/html "access plus 1 days"

2.Make a symbolic link to that file in the directory /etc/apache2/mods-enabled/:

# cd /etc/apache2/mods-enabled/ && ln -s ../mods-available/expires.load expires.load

3.Add the following line to the file /etc/apache2/apache2.conf:

FileETag None
4.Apply the configuration changes:

# service apache2 reload

5.Validate the Apache configuration:

# apache2ctl -t
Syntax OK

Check that the module is loaded:

6.apache2ctl -M | grep expires
# expires_module (shared)


Additional information

Depending on the type of content that is served, it might be required to enable caching for nginx too since different types of content is served by either nginx, or apache:

How to enable leverage browser caching for nginx?