Results 1 to 4 of 4

Thread: IIS7: Add expires header or cache-control header

  1. #1
    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?

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    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.

  3. #3
    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

  4. #4
    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.

Similar Threads

  1. Connect USB 3.0 front case panel header to motherboard w/o a header?
    By Dogs-Day-Out in forum Motherboard Processor & RAM
    Replies: 4
    Last Post: 14-04-2012, 07:02 PM
  2. Header first page only
    By Utanka in forum MS Office Support
    Replies: 3
    Last Post: 30-06-2009, 09:47 PM
  3. Php header problem
    By Deskmukh in forum Software Development
    Replies: 3
    Last Post: 07-05-2009, 07:41 PM
  4. Help Regarding Header Files
    By Jagdish Gada in forum Software Development
    Replies: 4
    Last Post: 06-03-2009, 12:58 PM
  5. bad_pool header
    By hippey in forum Windows XP Support
    Replies: 1
    Last Post: 13-02-2005, 11:23 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,537,506.24386 seconds with 17 queries