MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ASPNet
Author Message
Mike



Joined: 08 Aug 2007
Posts: 17

PostPosted: Sun Nov 25, 2007 11:57 am    Post subject: In ASP.NET can I cache a 's background image? Reply with 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

Archived from group: microsoft>public>dotnet>framework>aspnet
Back to top
View user's profile Send private message
Juan T. Llibre



Joined: 08 Aug 2007
Posts: 14

PostPosted: Sun Nov 25, 2007 4:50 pm    Post subject: Re: In ASP.NET can I cache a 's background image? Reply with quote

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" wrote in message @microsoft.com...
> 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
Back to top
View user's profile Send private message
Alexey Smirnov



Joined: 08 Aug 2007
Posts: 11

PostPosted: Sun Nov 25, 2007 6:58 pm    Post subject: Re: In ASP.NET can I cache a 's background image? Reply with quote

On Nov 25, 3:57 pm, Mike wrote:
> 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/cache_control_extensions.aspx
Back to top
View user's profile Send private message
Mike



Joined: 08 Aug 2007
Posts: 17

PostPosted: Mon Nov 26, 2007 2:51 pm    Post subject: Re: In ASP.NET can I cache a 's background image? Reply with quote

Thank you both for your help!

"Alexey Smirnov" wrote:

> On Nov 25, 3:57 pm, Mike wrote:
> > 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/cache_control_extensions.aspx
>
Back to top
View user's profile Send private message
Wainage



Joined: 29 Nov 2007
Posts: 2

PostPosted: Thu Nov 29, 2007 3:27 am    Post subject: RE: In ASP.NET can I cache a 's background image? Reply with quote

Easiest way ... CSS file

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

Browsers will cache background images.

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Simple one: Cache image from db This must have been asked a million times before, but I can't find any relevant information on how to do this. I store images in the database using something like this: | ImageID (Long)| Data (blob) | LastChanged (DateTime)| The images are not changing ve

Deserialize form's background image Hi, We have an application that allows users to design forms using some predefined controls - users place a set of controls on a designer form, and we compile the design into an assembly. The RootComponent is of a Form-derived class that we have developed

Dragging a form with a background image I have a form covered by an image. When, at runtime, I drag the form around the screen there is a lot of painting going on causing it to be really slow at updating. Obviously, I would like to eliminate this. On some appplications when you attempt to drag

Cache.Insert set absolute time but Cache become null immedia What am I doing wrong here? I am trying to Cache data for 5 minutes (absolute time). To test caching, I am writing to a log file every time the application determines that the Cache item is null and needs to pull the data from the database again. I run my

HttpContext cache vs HttpRuntime Cache Hi I want to know, - the difference between both the caching mechanism. - Where is the caching data stored in each situation. - Will HttpRuntime cache better than Context Cache for storing large amount of data or the reverse? Please send me your reply. Th
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ASPNet All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group