✕
Share it

Contact me
iPhone / iPad

Tools

Hindi Proof Reader Top Tech Blogs in India QR Code Generator
Make Money Online Earn from Blogging More Tools MS-Excel MS-Word AdSense About Lalit Contact us
TechWelkin Site Logo

TechWelkin

Tips and Tutorials on Computers, Mobiles and Internet

Last updated: 10 November 2014

How to Add Expires Header to Images

March 26, 2012 By Lalit Kumar 1 Comment

Learn to add expires header for images to cache images in browser and increase load speed of a website. You can add expires header in Apache and IIS Server.




Caching is a very important aspect that every webmaster must be aware of. Websites that do not properly utilize caching will load slowly in web browsers. Website speed is a crucial thing in the eyes of modern search algorithms. Images load slowest because of their bit size. Webpages full of images load terribly slow! Let’s learn how to use expires header to cache images.

Expires header tells browser how to cache a web page component. If a component (image, flash, html etc.) is not going to change for a long time in future –it is highly recommended that you add a far future expires header. In simple words, this means that you tell the browser to cache the component for a long time (several months or may be several years).

If you believe that a component is never going to change –you should add never expires header.

Add Expires Header for Images in Apache Server

In case you are using Apache server, you can use the following in .htaccess file:

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html "access plus 2 days"
ExpiresByType image/gif "access plus 60 days"
ExpiresByType image/jpg "access plus 60 days"
ExpiresByType image/png "access plus 60 days"
ExpiresByType application/x-javascript "access plus 60 days"
ExpiresByType text/css "access plus 60 days"
ExpiresByType image/x-icon "access plus 360 days"
</IfModule>

There is another way to accomplish the same thing. It is more concise mehtod:

<filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
</filesMatch>
Add Expires Header for Images in IIS Server

In case of IIS Server 7 or later, add the following code in web.config file’s system.webServer section

<staticContent>
 <clientCache httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" cacheControlMode="UseExpires" />
</staticContent>

This is how you can easily add expires header in Apache and IIS server. If you have control of your server, it is highly recommended to add these headers to enhance your website’s performance.

I hope it was useful. Please feel free to ask me if you have any question about this topic. I will be happy to try and help you. Thank you for using TechWelkin.

Related Articles for More Information:

  1. Drag and Drop Similar Image Search in Google Images
  2. Benefits of Loading jQuery from Google
  3. Tips: Purging MediaWiki File Cache Pages
  4. How to Easily Make a Website
Last updated: 10 November 2014 | Published on: 26 March 2012 | Authored and Edited by: Lalit Kumar and Team | Filed as: Home » Programming » Web development » How to Add Expires Header to Images

Filed Under: Web development

Lalit Kumar is the Principal Author and Founder of TechWelkin. He is a web explorer and he enjoys finding useful information on the Internet. He loves to put things together to create a bigger solution. Lalit is passionate about technology, languages and literature. You can contact Lalit via email (techwelkin [at] gmail [dot] com) or Facebook (facebook.com/techwelkin).

Comments

  1. emma williams says

    August 25, 2017 at 11:54 am

    Thank you for sharing this blog, it can really help me alot adding the expire tag.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

banner of the book 'Vitamin Zindagi'

Recent Stories

  • Cool Instagram Usernames for Girls and Boys
  • Best Custom Robots.txt File for Blogger/Blogspot
  • Check Ticket Confirmation PNR Status on WhatsApp
  • Easily Capture Screen and Do Recording on iPhone / iPad
  • Consistent Video Upload is Important for YouTube Channel
  • Conditions for YouTube Channel Monetization
  • How to Get Your First 100 and 1000 Subscribers on YouTube
  • What is the Average Audience Retention for YouTube Channels?

Tools

  • Hindi Proof Reader
  • Top Tech Blogs in India
  • QR Code Generator
  • Random Word Generator
  • Strong Password Generator
  • Trace Mobile Numbers

Connect with us

  • Facebook
  • Google+
  • Twitter
  • LinkedIn
  • Pinterest
  • RSS Feed

© 2007-2019 TechWelkin.
The content is copyrighted to Lalit Kumar and may not be reproduced on other websites.
TechWelkin displays Google AdSense ads. See how Google uses data when you're on TechWelkin | Privacy Policy