How to enable leverage browser caching for Apache in Plesk

Follow

Comments

19 comments

  • 0
    Comment actions Permalink
  • Avatar
    Vitaly Zhidkov

    @iamkingsleyf, you can enable mod_deflate module from Plesk > Tools & Settings > Apache Web Server

    > also this tutorial did not work as apache failed to start

    Can you share the error message?

    0
    Comment actions Permalink
  • Avatar
    Kingsley Felix

    Because after adding your code apache failed to start with an error

    0
    Comment actions Permalink
  • Avatar
    Vitaly Zhidkov

    @iamkingsleyf, what exact message was shown? You can find it under /var/log/httpd/error_log

    0
    Comment actions Permalink
  • Avatar
    Kingsley Felix

    its passed now so i can't recall

    0
    Comment actions Permalink
  • Avatar
    Stuart de Usoz

    Alexander, I'm running Plesk Onyx on Centos, and I followed your instructions and it works fine, thank you. However, I am wondering about "ETag none"  as I'm trying to find best way to always serve image files that have been modified yet cache may still be holding unmodified version.  I just was reading about using ETag and I remembered that I turned it off by following this instruction.   So, will these instructions still work if I remove "ETag none" ?  or do you have suggestion using Apache to always serve modified content?

    0
    Comment actions Permalink
  • Avatar
    Artyom Baranov

    @Stuart de Usoz,

    Hello! You may remove "FileETag None" from Apache config file. As far as I know, 'mod_expires' should not conflict with 'ETag'

    0
    Comment actions Permalink
  • Avatar
    IONOS Support

    Error on first step "path must precede expression"

     

    See attachment.

    0
    Comment actions Permalink
  • Avatar
    Artyom Baranov

    @1and1 Internet,

    Hello! You should use only the command from step #1:

    # find / -name mod_expires.so

    And `/usr/lib64/httpd/modules/mod_expires.so` is it's output.

    0
    Comment actions Permalink
  • Avatar
    Armin Wucherer

    Hi I have a Ubuntu enviroment and it does not work. 

    If I try the second thing I get already a error: # find / -name mod_expires.so
    find: '/sys/kernel/security/ima': Permission denied
    find: '/sys/kernel/security/apparmor': Permission denied
    find: '/sys/kernel/debug': Permission denied

    nevermind it is in /usr/lib/apache2/modules/mod_expires.so

    #3 would be # vi /etc/apache2/plesk.conf.d/expires.conf

    #4 interestingly there you have the right path

    #5 tried with that string and without

    #6 and #7 no error works fine

    #8 mod_expires does not apear in the list of loaded Apache modules

     

    any idea what I can do next? 

     

    cheers,  Armin 

     

    0
    Comment actions Permalink
  • Avatar
    Armin Wucherer

    just found the solution: move /etc/apache2/plesk.conf.d/expires.conf to /etc/apache2/conf-available/expires.conf and than link it in /etc/apache2/conf-enabled/expires.conf to the available conf file restart apache2 and it works fine

     

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    @Armin Wucherer

    I am glad the solution is found.
    The solution for Ubuntu will be added to this article

    0
    Comment actions Permalink
  • Avatar
    Ashkan Nasiri

    This KB guide us to enable "Leverage browser caching" on server level. However we want to make it domain level. 

    How can we achieve domain level "Leverage browser caching"?

    0
    Comment actions Permalink
  • Avatar
    Pavel Rozental

    @Ashkan Nasiri

    I have added this information to the article, check it.

    0
    Comment actions Permalink
  • Avatar
    lenala

    Where is the guide "For particular subscription" ??? Because I don't think this is correct :

    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:

    0
    Comment actions Permalink
  • Avatar
    Anton Maslov

    @lenala thank you for noticing, article was fixed!

    0
    Comment actions Permalink
  • Avatar
    El fadili bouchta

    what about the mode with nginx

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Hello El fadili bouchta

    Here is the link to requested instruction: https://support.plesk.com/hc/en-us/articles/115001374153-How-to-enable-leverage-browser-caching-for-nginx-

    0
    Comment actions Permalink
  • Avatar
    Md Ashraf Malik (Edited )

    To enable leverage browser caching on Apache, please follow these simple steps:

    1. Login into your Cpanel.
    2. Locate the .htaccess file in the root directory.
    3. Open the .htaccess file in your web browser.
    4. Append IfModule code in your .htaccess file provided below.
    5. Finally, save the .htaccess file and test results.

    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access 1 year"
    ExpiresByType image/jpeg "access 1 year"
    ExpiresByType image/gif "access 1 year"
    ExpiresByType image/png "access 1 year"
    ExpiresByType text/css "access 1 month"
    ExpiresByType application/pdf "access 1 month"
    ExpiresByType application/x-javascript "access 1 month"
    ExpiresByType application/x-shockwave-flash "access 1 month"
    ExpiresByType image/x-icon "access 1 year"
    ExpiresDefault "access 2 days"
    </IfModule>

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request