Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Caching / April 2004

Tip: Looking for answers? Try searching our database.

JPG, CSS, XML Caching

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Scott Simes - 24 Apr 2004 23:40 GMT
Keywords: image cache caching css stylesheet expire expiration asp.net c#
==================================================

I'm using ASP.NET and C#.

I'm trying to figure out if it's possible to set the expiration date or the
last modified date for certain documents that get streamed to the user's
browser. For example, I use the following HTML to link a stylesheet to an
ASPX document:

  LINK href="menuStyle.css" type="text/css" rel="stylesheet">

I want the .css file that gets written to the user's browser to expire in
one day, so that a fresh style sheet is obtained the next day.

The same goes for certain images, such as JPG and GIF files.

Ideally, I want to be able to control image expiration on an image-by-image
basis; the same goes for the css files.

Any ideas would be appreciated.
Dino Chiesa [Microsoft] - 30 Apr 2004 21:11 GMT
ASP.NET has an interface to cache the content it generates.  It looks like
this in the page:
<%@ OutputCache Duration="#ofseconds">

One of the elements you can specify is the length in time the item should be
cached.
http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconOutputCache.asp

So, if you dynamically generate these web artifacts (css, jpg, htm, xml,
whatever) from an ASP.NET page, then you should be able to use something
like the OutputCache to do it.  Eg within page 1 do this:

<LINK href="MyStyleGenerator.aspx" type="text/css" rel="stylesheet">

and within MyStyleGenerator.aspx, use the OutputCache declaration.

Of course, within the ASPX that generates the CSS, you need to set the
content-type appropriately for the type of content you are dynamically
rendering.

Separate note:
ASP.NET can use the IIS6 kernel cache, if you use VaryByParam="none"
http://geekswithblogs.net/ewright/archive/2003/10/24/241.aspx

This has a nice perf advantage, because the IIS6 cache is served from kernel
space.  This means no context switching to deliver cache results to the
requester.  Speedy.
If the VaryByParam is not none, the cache still works as advertised, but it
is not served from the kernel listener (http.sys).  Instead it is served
from ASP.NET, which means the cache doesn't perform as well.  Still better
than not caching at all though.

-Dino

> Keywords: image cache caching css stylesheet expire expiration asp.net c#
> ==================================================
[quoted text clipped - 17 lines]
>
> Any ideas would be appreciated.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.