Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set expiration headers for CSS, JS, and Images for blogspot site

I checked my site with google page speed.

It said Specify an expiration for my resources.

Can anyone tell me how to leverage browser caching for blogger?

like image 364
cutiehulk2329 Avatar asked Aug 25 '12 14:08

cutiehulk2329


2 Answers

You cannot set custom expiration for resources served by Blogger - that part is already done for you by Google servers. Having said that, if you serve content from any third party domains (which you are), then you should look into enabling compression and caching on those hosts.

Of course, sometimes this will be out of your control - ex, third party widgets which you do not control directly.

like image 140
igrigorik Avatar answered Oct 17 '22 06:10

igrigorik


You will have to set the expires header in your hosting settings. If you have hosted your website on Google App Engine (which is free) you can set the expires header in webapp-web.xml to 10 days.

<include path="/assets/**.css" expiration="10d" /> 
<include path="/assets/**.js" expiration="10d" /> 

I have gone through your site and have seen that you use blogger for articles, you can not set the expires header for blogger images and posts.

I have used Google's infrastructure to host my images, CSS and JS files. But if you want to improvise your pagespeed score on you custom JS files and CSS files, my blogger post can help you to host static content in Google. My blogs pagespeed score is around 94.

Disclaimer: I have authored the post mentioned in the link.

If you are hosting your CSS and JS files in some other hosting location, you should look for help to set the expires header in case you are using Apache web server to host.

like image 27
Raghu Kiran Avatar answered Oct 17 '22 06:10

Raghu Kiran