Adding Expiration Date To Headers

I’ve been tweaking the performance of BlogEngine.NEXT today using my favorite tool: YSlow for FireBug. One of the things YSlow checks for is the expires HTTP header for static content such as images, script files and style sheets. Since BlogEngine.NET has always used custom HTTP handlers for serving scripts and stylesheets, only the static images have been a problem.

The problem

The problem is that with images on hosted environments on IIS 6, it’s impossible to control the serving of them without redirecting them through an HTTP handler. That’s not a good idea for several reasons:

  • It adds unnecessary overhead by going through the ASP.NET ISAPI
  • You need to add custom code to handle the requests
  • You need to change the URL from .gif to .gif.axd or similar

Here is what YSlow finds on my website that needs the expires header set to a far future date:

As you can see, it is all my static images that lacks the expires header.

The solution

If you run IIS 6 there is no good way of adding an expires header to images unless you have control over the IIS. If your site is hosted then you probably have no control at all. If you are using IIS 7 however, you can very easily add the header in your web.config’s system.webServer section like so:

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

What happens is that all static content will now have an expires HTTP header set to the year 2020. Static content means anything that isn’t served through the ASP.NET engine such as images, script files and styles sheets. This is one of the very easy tricks that will increase the performance of your site as well as your YSlow score.

Comments

Mads Kristensen
About Mads Kristensen
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution. http://www.madskristensen.dk/

183 thoughts on “Adding Expiration Date To Headers

  1. Pingback: xxxcams.mobi

  2. Pingback: mxkoedfurvxcbxcvdhfeye

  3. Pingback: vwemkfluygvzsdiohfse

  4. Pingback: czxmvxbjhegyfsegfvsdg

  5. Pingback: fmsdkugshfvjkdhfgvsdfvsdf

  6. Pingback: gklsdfngskjhgbjhxdvndshg

  7. Pingback: acsgvedhbnkmglhkmjnhjbvs

  8. Pingback: mcnfgxmrfshdchnfsxjrfsgdvfd

  9. Pingback: zcmvjnergujefvbfasdkjshvdfbv

  10. Pingback: gdsnxcrtkmfcffvshggsdfsvsd

  11. Pingback: fgkxcmfvsdffsdbvsesvsdfvsdv

  12. Pingback: raspberry ketones

  13. Pingback: forskohlii

  14. Pingback: review

  15. Pingback: raspberry ketones diet

  16. Pingback: Blue Coaster33

  17. Pingback: Scarves for Women

  18. Pingback: forskolin coleus forskohlii

  19. Pingback: madrid

  20. Pingback: dr oz fat burning pills

  21. Pingback: raspberry ketone diet

  22. Pingback: garcinia cambogia extract ultra

  23. Pingback: hcg solution

  24. Pingback: Ecom Masters FBA Edition Review

  25. Pingback: Guest Blogging

  26. Pingback: quantum vision system steps

  27. Pingback: quantum vision reviews

  28. Pingback: sigint system

  29. Pingback: kieliszki jako prezenty dla mlodej pary

  30. Pingback: BHP Opole

  31. Pingback: Warszawa ksiegowosc

  32. Pingback: yomega

  33. Pingback: grainger discount code may 2015 promo coupon off

  34. Pingback: Tienda

  35. Pingback: forskolin

  36. Pingback: play rainbow riches slot

  37. Pingback: streaming movies

  38. Pingback: watch tv show episodes

  39. Pingback: stream movies

  40. Pingback: watch movies online

  41. Pingback: stream movies

  42. Pingback: streaming movies

  43. Pingback: tv online, online tv

  44. Pingback: watch tv show episodes

  45. Pingback: free movie downloads

  46. Pingback: watch free movies online

  47. Pingback: dr oz weight loss supplement

  48. Pingback: pure forskolin extract

  49. Pingback: best fat burning pills

  50. Pingback: lotto srategies

  51. Pingback: e-commerce

  52. Pingback: Video Motion Pro review

  53. Pingback: Facebook

  54. Pingback: debt collection

  55. Pingback: sewa mobil surabaya

  56. Pingback: debt collectors

  57. Pingback: http://www.sommerkleid2015.com

  58. Pingback: cheap sunglasses

  59. Pingback: obattradisionalkolesterol.rajapengobatan.com

  60. Pingback: sell for free

  61. Pingback: green bean coffee pills

  62. Pingback: Video Sales Blueprint

  63. Pingback: how to get the skinny pill

  64. Pingback: The

  65. Pingback: green coffee extract cleanse

  66. Pingback: IM Profit Formula

  67. Pingback: best harrisburg dui attorney

  68. Pingback: IntelliPlayer Review

  69. Pingback: best supplements for nitric oxide

  70. Pingback: SEO company Los Angeles

  71. Pingback: reel king slot

  72. Pingback: build my list

  73. Pingback: nordfx

  74. Pingback: click here for flagstone patio designs

  75. Pingback: gps tracker

  76. Pingback: Facebook

  77. Pingback: garcinia cambogia reviews

  78. Pingback: rewind yoyo

  79. Pingback: ship enemies glitter

  80. Pingback: play ooh aah dracula

  81. Pingback: Cloud Prospect Machine Bonus

  82. Pingback: garcinia xt and natural cleanse

  83. Pingback: My Top Tier Business Review

  84. Pingback: Onkyo TX-NR636

  85. Pingback: candellux i eglo 7i9

  86. Pingback: AVR-X4100W

  87. Pingback: dr oz diet pill garcinia cambogia

  88. Pingback: Status Labs

  89. Pingback: On

  90. Pingback: binary options nadex

  91. Pingback: HD26 Projector

  92. Pingback: check these guys out

  93. Pingback: where to sell items online,

  94. Pingback: howzthat.org

  95. Pingback: The

  96. Pingback: Tee Marketing Academy Review

  97. Pingback: nitric oxide best supplement

  98. Pingback: wired mouse

  99. Pingback: best nitric oxide supplements

  100. Pingback: SocialNeos

  101. Pingback: moje wesele warszawa

  102. Pingback: Onkyo TX-NR535 5.2-Channel Network A/V Receiver

  103. Pingback: foxin wins again slot machine

  104. Pingback: uk online casinos

  105. Pingback: best online casinos

  106. Pingback: Click

  107. Pingback: Video App Domination Review

  108. Pingback: clash of clans hack tool

  109. Pingback: Onkyo TX-NR838 7.2-Ch Dolby Atmos Ready Network A/V Receiver

  110. Pingback: pestovani chilli

  111. Pingback: best steroid for strength

  112. Pingback: Cocksluts of the caribeean03

  113. Pingback: Earphones

  114. Pingback: iherb coupon July 2015

  115. Pingback: Polecam

  116. Pingback: inventhelp commercials

  117. Pingback: tvpackages.net

  118. Pingback: Onkyo TX-SR333 Review

  119. Pingback: Onkyo HT-S3700

  120. Pingback: If

  121. Pingback: Business Directory Australia

  122. Pingback: DIRECTV vs Dish

  123. Pingback: sie sucht ihn

  124. Pingback: beachside drug rehab

  125. Pingback: beachside rehab

  126. Pingback: Canadian Made Gun Parts

  127. Pingback: parking

  128. Pingback: lan penge nu 18 ar

  129. Pingback: bedste lan lige nu

  130. Pingback: Click

  131. Pingback: mp4 mobile porn

  132. Pingback: New Bingo Sites

  133. Pingback: Marcus Mariota NFL Jersey

  134. Pingback: ClickPress

  135. Pingback: Marcy ME 709

  136. Pingback: Marcy Diamond Elite

  137. Pingback: laan penge nu uden renter

  138. Pingback: distance meter

  139. Pingback: Weider Power Tower

  140. Pingback: ? F??t?r D??t

  141. Pingback: phuket rent

  142. Pingback: Online lead generation

  143. Pingback: Paginaswebtoledo

  144. Pingback: Click

  145. Pingback: 1900 Total Gym

  146. Pingback: her og nu laan

  147. Pingback: water ionizers

  148. Pingback: Brooks Brothers coupon code June 2015

  149. Pingback: Cam Sex

  150. Pingback: asian cams

  151. Pingback: Weider Ultimate Body Works Review

  152. Pingback: Youtube

  153. Pingback: Body Solid Series 7 GS348P4 Smith Machine Gym

  154. Pingback: solid gfid225

  155. Pingback: car parking

  156. Pingback: Body Champ IT8070

  157. Pingback: Ironman Gravity 4000 Inversion Table Review

  158. Pingback: harga

  159. Pingback: Stereo earbuds

  160. Pingback: powerline ppr200x power rack

  161. Pingback: Cheap Web Hosting

  162. Pingback: car phone holder

  163. Pingback: link building outsource

  164. Pingback: PowerBlock Elite 90 Review

  165. Pingback: water ionizer pay plan loans

  166. Pingback: ironmaster adjustable super bench

  167. Pingback: bottled alkaline water

  168. Pingback: ironmaster adjustable dumbbells Review

  169. Pingback: Our Webpage

  170. Pingback: pay per day loan plans

  171. Pingback: hummingbird twitter software

  172. Pingback: dedicated hosting at CheapWebHostingSpot.com

  173. Pingback: rosegal promo code

  174. Pingback: Email Instruments

  175. Pingback: pandahall coupon

  176. Pingback: Facebook

  177. Pingback: Facebook

  178. Pingback: acompanhantes niteroi

  179. Pingback: If

  180. Pingback: konferencje mazury

  181. Pingback: 100k factory

  182. Pingback: Freshmaza DJ Music Download

  183. Pingback: twitter hummingbird redux

Leave a Reply