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 / November 2003

Tip: Looking for answers? Try searching our database.

VaryByControl and Cache Dependency

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joseph - 12 Nov 2003 07:53 GMT
Hi,

I am trying to set up fragment caching by using the VaryByControl attribute
in a page directive in an ascx file.  At the same time I also need to set
the output response of the user control to be dependent on a file so that I
can invalidate the cache when the content of the file has been changed even
before the cache expired. So I set up file dependency to the output response
of the user control in the Page_Load event in the ascx file. The
VaryByControl works fine and it caches a version of the user control when
different values of the controls specified in the VaryByControl attribute
are set. However, the file dependency did not work. When the file got
removed or modified it used the cache version of the user control (if it
existed before) instead of creating a new instance of user control. Can the
VaryByControl in page directive and file dependency work together in an ascx
file? If not, is there a way to programmatically do what VaryByControl is
supposed to do in the code-behind?

Here is my page directive in the ascx file:

<%@ OutputCache duration="300" VaryByControl="ctl1,ctl2, ctl3" %>

Here is the code I used to set the file dependency to the output response in
the Page_Load() event in the ascx file:

Page.Response.AddFileDependency("C:\\testfile.txt");

thanks in advance.
MSFT - 13 Nov 2003 09:20 GMT
You may wan to look at AddCacheItemDependency and AddCacheItemDependencies
methods of HTTPReponse object, they may help on this issue:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemwebhttpresponseclassaddcacheitemdependencytopic.asp

Luke
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Joseph - 13 Nov 2003 09:33 GMT
how does AddCacheItemDependency help in my case? I want the output response
to be dependent on a file rather than a cache object.

Please elaborate.

Thanks.
> You may wan to look at AddCacheItemDependency and AddCacheItemDependencies
> methods of HTTPReponse object, they may help on this issue:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
> frlrfsystemwebhttpresponseclassaddcacheitemdependencytopic.asp
>
[quoted text clipped - 4 lines]
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
MSFT - 14 Nov 2003 08:07 GMT
Hi Joseph,

AddFileDependency is set to cache the web page, VaryByControl is set to the
cache the web control. AddCacheItemDependency may help us when the cached
page is change and we need to change the cached web control.

Luke
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


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.