browser caching

pardis

Well-Known Member
#1
Hi Guys :

How can possible enable browser caching in litespeed ?
I used following instruction : https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:browser_cache

but still get error in Gtmetix about this time set to 30s , although lsws set 1 week.
Also I added following code to .htaccess and this not help me.

Code:
<IfModule mod_expires.c>
  ExpiresActive On

  # Images
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/gif "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType image/x-icon "access plus 1 year"

  # Video
  ExpiresByType video/mp4 "access plus 1 year"
  ExpiresByType video/mpeg "access plus 1 year"

  # CSS, JavaScript
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType text/javascript "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"

  # Others
  ExpiresByType application/pdf "access plus 1 month"
  ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>
with above code in Apache webserver i didnt get any error in Gtmetix .
Please guide .

Thanks a lot
 

Unique_Eric

Administrator
Staff member
#2
Does it work if you apply default lscachewp browser cache rules
Code:
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType application/pdf A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType image/vnd.microsoft.icon A2592000
ExpiresByType image/svg+xml A2592000

ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/png A2592000
ExpiresByType image/gif A2592000
ExpiresByType image/webp A2592000

ExpiresByType video/ogg A2592000
ExpiresByType audio/ogg A2592000
ExpiresByType video/mp4 A2592000
ExpiresByType video/webm A2592000

ExpiresByType text/css A2592000
ExpiresByType text/javascript A2592000
ExpiresByType application/javascript A2592000
ExpiresByType application/x-javascript A2592000

ExpiresByType application/x-font-ttf A2592000
ExpiresByType application/x-font-woff A2592000
ExpiresByType application/font-woff A2592000
ExpiresByType application/font-woff2 A2592000
ExpiresByType application/vnd.ms-fontobject A2592000
ExpiresByType font/ttf A2592000
ExpiresByType font/woff A2592000
ExpiresByType font/woff2 A2592000

</IfModule>
 

serpent_driver

Well-Known Member
#4
Pagespeed Insights expects atleast 31536000 seconds for cache-control, but you need to add "Cache-Control" Header to your .htaccess. ExpiresByType does not control browser cache behavior.

Code:
# Add or remove file types if needed
<FilesMatch "\.(jpg|jpeg|woff|woff2|png|gif|swf|ico|js|css|ttf|eot|ico|js|mp4|webm|svg|json)$">
Header set Cache-Control "max-age=31536000, public, no-transform"
</FilesMatch>
Cache Control and Expires is not a Litespeed owned directive.
 
Last edited:
#5
Pagespeed Insights expects atleast 31536000 seconds for cache-control, but you need to add "Cache-Control" Header to your .htaccess. ExpiresByType does not control browser cache behavior.

Code:
# Add or remove file types if needed
<FilesMatch "\.(jpg|jpeg|woff|woff2|png|gif|swf|ico|js|css|ttf|eot|ico|js|mp4|webm|svg|json)$">
Header set Cache-Control "max-age=31536000, public, no-transform"
</FilesMatch>
Cache Control and Expires is not a Litespeed owned directive.
thank you for this great information. i would never find.
 
#6
Pagespeed Insights expects atleast 31536000 seconds for cache-control, but you need to add "Cache-Control" Header to your .htaccess. ExpiresByType does not control browser cache behavior.

Code:
# Add or remove file types if needed
<FilesMatch "\.(jpg|jpeg|woff|woff2|png|gif|swf|ico|js|css|ttf|eot|ico|js|mp4|webm|svg|json)$">
Header set Cache-Control "max-age=31536000, public, no-transform"
</FilesMatch>
Cache Control and Expires is not a Litespeed owned directive.
I don't know but for some reason, It won't work for me https://d.pr/i/FfdkVz
Do I need to delete the default Litespeed cache setting from htaccess?
 
Top