Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[WordPress][WP Rocket] Add browser caching rule to .htaccess; example: zero browser caching for PDF files
<?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

This comment has been minimized.

Copy link

@tanmoy-web tanmoy-web commented Feb 29, 2020

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

@glueckpress

This comment has been minimized.

Copy link
Owner Author

@glueckpress glueckpress commented Mar 2, 2020

@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.

@tanmoy-web

This comment has been minimized.

Copy link

@tanmoy-web tanmoy-web commented Mar 2, 2020

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.