Connecting Tech Pros Worldwide Forums | Help | Site Map

In ASP.NET can I cache a <body>'s background image?

=?Utf-8?B?TWlrZQ==?=
Guest
 
Posts: n/a
#1: Nov 25 '07
Hi. I'm building an ASP.NET 2.0 web-app for a customer. The customer wants
a background image that's 124k in size as the background for each page. I've
recommended they use a smaller-size image, but the customer is absolutely
adamant about using the image.

I'm afraid that this large image will degrade performance if it's loaded for
each page. Can I somehow use ASP.NET caching to cache the background image
so it doesn't have to refresh on each page load?

Thanks, Mike

Juan T. Llibre
Guest
 
Posts: n/a
#2: Nov 25 '07

re: In ASP.NET can I cache a <body>'s background image?


Set a custom header, which specifies "max-age".

Open the IIS Manager snap-in from Administrative Tools, pick an app,
right click, go to Properties, switch to the HTTP Headers tab, and click Add.

Add cache-control extensions like this:

In the "Custom Header Name", type : Cache-Control

In the Custom Header Value, type :

"Cache-Control:max-age=NumberOfSeconds"

OK your way out of the dialog...

I use :
"Cache-Control:max-age=1200"
....which will cache images for the default session timout ( 20 minutes ).





Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
======================================
"Mike" <Mike@discussions.microsoft.comwrote in message news:2386CD3B-085E-4A98-B1B1-D8F78D57A332@microsoft.com...
Quote:
Hi. I'm building an ASP.NET 2.0 web-app for a customer. The customer wants
a background image that's 124k in size as the background for each page. I've
recommended they use a smaller-size image, but the customer is absolutely
adamant about using the image.
>
I'm afraid that this large image will degrade performance if it's loaded for
each page. Can I somehow use ASP.NET caching to cache the background image
so it doesn't have to refresh on each page load?
>
Thanks, Mike

Alexey Smirnov
Guest
 
Posts: n/a
#3: Nov 25 '07

re: In ASP.NET can I cache a <body>'s background image?


On Nov 25, 3:57 pm, Mike <M...@discussions.microsoft.comwrote:
Quote:
Can I somehow use ASP.NET caching to cache the background image
so it doesn't have to refresh on each page load?
>
Mike, you can also write a custom HttpHandler and map images to the
ASP.NET ISAPI in IIS. And then from ASP.NET you will be able to add
cache contol values, the same what Juan told you

Response.Cache.AppendCacheExtension("max-age=NumberOfSeconds");

I would also recommend you to check:
http://aspnetresources.com/blog/cach...xtensions.aspx
=?Utf-8?B?TWlrZQ==?=
Guest
 
Posts: n/a
#4: Nov 26 '07

re: In ASP.NET can I cache a <body>'s background image?


Thank you both for your help!

"Alexey Smirnov" wrote:
Quote:
On Nov 25, 3:57 pm, Mike <M...@discussions.microsoft.comwrote:
Quote:
Can I somehow use ASP.NET caching to cache the background image
so it doesn't have to refresh on each page load?
>
Mike, you can also write a custom HttpHandler and map images to the
ASP.NET ISAPI in IIS. And then from ASP.NET you will be able to add
cache contol values, the same what Juan told you
>
Response.Cache.AppendCacheExtension("max-age=NumberOfSeconds");
>
I would also recommend you to check:
http://aspnetresources.com/blog/cach...xtensions.aspx
>
=?Utf-8?B?V2FpbmFnZQ==?=
Guest
 
Posts: n/a
#5: Nov 29 '07

re: In ASP.NET can I cache a <body>'s background image?


Easiest way ... CSS file

-------------------------------------------------------------
body { background-image: url( 'images/massivepic.jpg' ); }
-------------------------------------------------------------

Browsers will cache background images.

Closed Thread