Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 06-06-2009
Member
 
Join Date: Jan 2009
Posts: 55
IIS7: Add expires header or cache-control header

I am running a website. I am using IIS7 and Apache HTTP Server for my website. I recently noticed that a lot of load on my server due to continuous request from some users who visit my website regularly. This creates a massive load to my server and even increases log file size. I would like to reduce this request from the users side. Is this possible? I think I should cache some information at the users computers to decrease the load. But I am confused between what to use: expires header or cache-control header. Can you guide me in this matter?
Reply With Quote
  #2  
Old 06-06-2009
Member
 
Join Date: May 2008
Posts: 2,383
Re: IIS7: Add expires header or cache-control header

A new visitor generates several HTTP requests to download all files from your website, but you can reduce this usage for regular visitors with the help of "Expires header". It allows you to cache those files. This stops unnecessary HTTP requests. But the point is that you should use it on all your components.

Code:
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Fri, 10 Mar 2011 20:00:00 GMT"
</FilesMatch>
The above code goes in your root .htaccess file.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #3  
Old 06-06-2009
Member
 
Join Date: May 2008
Posts: 685
Re: IIS7: Add expires header or cache-control header

With Cache-Control headers, you can define which proxies can cache your site content, and also determine how long files can be cached. You can also force to check if the cache is having the most recent information.

Code:
# 720 weeks
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290804000, public"
</FilesMatch>
 
# 3 DAYS
<FilesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=171800, public, must-revalidate"
</FilesMatch>
 
# 5 HOURS
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=9600, must-revalidate"
</FilesMatch>
The above code goes into your root .htaccess file
Reply With Quote
  #4  
Old 06-06-2009
XSI XSI is offline
Member
 
Join Date: May 2008
Posts: 271
Re: IIS7: Add expires header or cache-control header

You can easily add the expires header in your web.config?s system.webServer section using IIS7:

Code:
<staticContent>
 <clientCache httpExpires="Mon, 1 May 2010 05:00:00 GMT" cacheControlMode="UseExpires" />
</staticContent>
This allows all the static content to have an expires HTTP header set to 2010. The static content may refer to anything which is not served through ASP.NET engine such as photos, script files and stylesheets.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "IIS7: Add expires header or cache-control header"
Thread Thread Starter Forum Replies Last Post
Connect USB 3.0 front case panel header to motherboard w/o a header? Dogs-Day-Out Motherboard Processor & RAM 4 14-04-2012 07:02 PM
Header first page only Utanka MS Office Support 3 30-06-2009 09:47 PM
Php header problem Deskmukh Software Development 3 07-05-2009 07:41 PM
Help Regarding Header Files Jagdish Gada Software Development 4 06-03-2009 12:58 PM
bad_pool header hippey Windows XP Support 1 13-02-2005 11:23 AM


All times are GMT +5.5. The time now is 12:14 PM.