Created
April 5, 2018 08:51
-
-
Save glueckpress/cc3c72cf08b7bd01bc161a5ddb3a661e to your computer and use it in GitHub Desktop.
[WordPress][WP Rocket] Add browser caching rule to .htaccess; example: zero browser caching for PDF files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Zero browser caching for PDF files. | |
*/ | |
add_filter( 'rocket_htaccess_mod_expires', function ( $rules ) { | |
$rules .= '# Expires headers for PDF' . PHP_EOL; | |
$rules .= '<IfModule mod_expires.c>' . PHP_EOL; | |
$rules .= 'ExpiresByType application/pdf "access plus 0 seconds"' . PHP_EOL; | |
$rules .= '</IfModule>' . PHP_EOL . PHP_EOL; | |
return $rules; | |
} ); |
@tanmoy-web The best advise I have is turn to the WP Rocket documentation and/or contact their support. Also, that particular warning doesn’t always mean something is wrong on your site; it could also be a third-party script that is loaded on your site but it’s origin server doesn’t support browser caching.
Thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am using wp rocket pro plugin for my website, but my website showing leverage browser caching warning. I am trying to fix these issues but do not work. so, what should I do now?
My website here: https://wcblogs.com