Jump to content

Recommended Posts

Posted

Greetings!

 

Am a developer, new to the business.

 

while going across google page speed for the simplest site hosted by me,

i came across some issues:

 

  • Should Fix: Eliminate render-blocking JavaScript and CSS in above-the-fold content
  • Consider Fixing: Leverage browser caching

 

i have googled the problem but was unable to find a quick and specific solution.

 

Can Someone Help?

 

 

Posted

Here's an example of browser caching that I use. Just create a .htaccess file in your web root with the contents

 

# Cache
ExpiresActive On
ExpiresDefault A0
 
# 1 YEAR - doesn't change often
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
  ExpiresDefault A31536000
</FilesMatch>
 
# 1 WEEK - possible to be changed, unlikely
<FilesMatch "\.(js|css|jpg|jpeg|png|gif|swf)$">
  ExpiresDefault A604800
</FilesMatch>
 
# 3 HOUR - core content, changes quickly
<FilesMatch "\.(txt|xml)$">
  ExpiresDefault A10800
</FilesMatch>
 
# 1 YEAR
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
  Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
 
# 1 WEEK
<FilesMatch "\.(js|css|jpg|jpeg|png|gif|swf)$">
  Header set Cache-Control "max-age=604800, public"
</FilesMatch>
 
# 3 HOUR
<FilesMatch "\.(txt|xml)$">
  Header set Cache-Control "max-age=10800"
</FilesMatch>
 
# NEVER CACHE - notice the extra directives
<FilesMatch "\.(html|htm|php|cgi|pl)$">
  Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
</FilesMatch>
 
<FilesMatch ".(js|css)$">
  Header append Vary: Accept-Encoding
</FilesMatch>


Here's a good guide for getting the above the fold content to load faster on your page https://varvy.com/pagespeed/render-blocking.html

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...