How to Speed up WordPress Leveraging Browser Caching via .htaccess

33

Leverage browser caching to make your webpages faster. If you can leverage browser caching, you can increase website speed considerably. As Google starts considering site speed as a SEO parameter, webmasters can leverage browser caching to improve site speed and get better search engine rankings.

Getting rid of ETag

First of all, we need to disable ETag header since we are going to use Expires. ETag technology is known as slow and problematic – even YSlow complains about it.

Add to .htaccess: (located at blog’s root location)

Header unset Pragma
FileETag None
Header unset ETag

Why browser caching?

If you set an expiry date or a maximum age in the HTTP headers for static resources, modern browsers will load previously downloaded static resources like images, css, javascript, pdf, swf etc. from local disks rather than over the network.

So if you configure your web server to set caching headers and apply them to all cacheable static resources, your site will appear to load much faster. Add below to .htaccess

 

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg “access 1 year”
ExpiresByType image/jpeg “access 1 year”
ExpiresByType image/gif “access 1 year”
ExpiresByType image/png “access 1 year”
ExpiresByType text/css “access 1 month”
ExpiresByType text/html “access 1 month”
ExpiresByType application/pdf “access 1 month”
ExpiresByType text/xjavascript “access 1 month”
ExpiresByType application/xshockwaveflash “access 1 month”
ExpiresByType image/xicon “access 1 year”
ExpiresDefault “access 1 month”
</IfModule>
## EXPIRES CACHING ##

What this does is adding far future expires header (make sure mod_expires is loaded in your apache config if you have problems) to your static content (images, js, css, etc).

Compress Components

Compressing things always ends up making them smaller and load faster, so implementing some form of compression on your components is a must. This optimization step might not work for you if your server does not have either mod_deflate or mod_gzip installed as part of Apache.

<FilesMatch “\\.(js|css|html|htm|php|xml)$”>
SetOutputFilter DEFLATE
</FilesMatch>

 

<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgiscript$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/xjavascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^ContentEncoding:.*gzip.*
</IfModule>

说点什么

881 评论 在 "How to Speed up WordPress Leveraging Browser Caching via .htaccess"

提醒
排序:   最新 | 最旧 | 得票最多

来看看,学习学习!!

学习带来乐趣,谢谢博主!

Hi! The scariest book I’ve ever read was &#T8#0;I2&28221;. It reached deep into my subconsciousness and scared the heck out of me! For Halloween I’ll be dragging out my Elmo snuggy for my couch potato costume. ~Lynn

My brother suggested I might like this blog.
He used to be totally right. This post actually made my
day. You cann’t consider just how so much time I had spent for this information! Thanks!

MMgU9p Looking forward to reading more. Great article post.Much thanks again. Want more.

This excellent website truly has all of the information and facts I wanted about this subject and didn at know who to ask.

really useful material, in general I imagine this is worthy of a book mark, many thanks

Some genuinely good posts on this web site , thankyou for contribution.

You should participate in a contest for the most effective blogs on the web. I will suggest this site!

Pretty! This was a really wonderful post. Thank you for supplying this information.

When I look at your blog site in Firefox, it looks fine but when opening in Internet Explorer, it has some

You made some nice points there. I did a search on the subject and found most guys will approve with your site.

Really informative article post.Much thanks again. Really Cool.

There are some attention-grabbing closing dates on this article however I don抰 know if I see all of them heart to heart. There’s some validity however I’ll take hold opinion till I look into it further. Good article , thanks and we wish more! Added to FeedBurner as properly

I love it when people come together and share thoughts.
Great blog, keep it up!

Nice post. I study one thing more challenging on completely different blogs everyday. It would all the time be stimulating to read content material from other writers and follow a bit something from their store. I抎 favor to use some with the content material on my blog whether or not you don抰 mind. Natually I抣l offer you a link on your internet blog. Thanks for sharing.

Really appreciate you sharing this blog.Really looking forward to read more. Keep writing.

up to other users that they will help, so here it occurs.

Thank you ever so for you blog.Thanks Again. Fantastic.

Say, you got a nice blog post.Really looking forward to read more. Will read on

Very good article. I certainly appreciate this site. Continue the good work!

your excellent writing because of this problem.

Major thanks for the article.Really thank you! Will read on

Thanks-a-mundo for the blog article.Much thanks again. Much obliged.

That is a great tip particularly to those fresh to the blogosphere. Short but very precise information Thank you for sharing this one. A must read article!

This website really has all the information and facts I wanted about this subject and didn at know who to ask.

What blogging website had the least invasive ads for free-account users?. Or what blogging website is best for someone looking to start a professional literary blog?.

WONDERFUL Post.thanks for share..more wait .. ?

Muchos Gracias for your article post.Thanks Again. Fantastic.

Hi! This is my 1st comment here so I just wanted to give a quick shout out and say I really enjoy
reading your blog posts. Can you suggest any
other blogs/websites/forums that deal with the same topics?
Thanks!

Lululemon Canada Factory Outlet Sale Online WALSH | ENDORA

I think this is a real great article post. Awesome.

Looking forward to reading more. Great blog article.Really thank you! Will read on

Looking forward to reading more. Great article.Really thank you! Really Cool.

Regards for helping out, great information.

Muchos Gracias for your blog post. Keep writing.

I cannot thank you enough for the post.Much thanks again. Want more.

I am commenting to make you know of the excellent encounter my cousin’s daughter went through visiting the blog. She mastered some pieces, most notably how it is like to possess an excellent teaching character to let the others really easily understand a number of extremely tough things. You truly did more than readers’ expected results. Many thanks for coming up with these practical, safe, revealing and cool tips about that topic to Julie.

Really enjoyed this article post.Really looking forward to read more. Awesome.

I really enjoy the post.Much thanks again. Cool.

Wow, great post.Thanks Again. Fantastic.

Looking forward to reading more. Great article.Really thank you! Awesome.

That is a great tip especially to those new to the blogosphere. Short but very accurate information Appreciate your sharing this one. A must read article!

Thanks for the blog post.Much thanks again. Awesome.

Muchos Gracias for your article.Really looking forward to read more. Keep writing.

I really liked your blog.Really looking forward to read more. Want more.

I value the article post.Really looking forward to read more. Really Cool.

I’m usually to blogging and i actually admire your content. The article has actually peaks my interest. I am going to bookmark your site and preserve checking for brand spanking new information.

I went over this internet site and I believe you have a lot of fantastic info, saved to fav (:.

Some great info on your blog, I want to read more as soon as I have sometime.

wpDiscuz