We have developed a Virtual Path Provider and a custom cachedependency for our aspx pages. Everything seems to be working just fine since we serve and invalidate aspx pages. The issue is that some machines retrieve a fresh copy of the form on first request
while others reuse a previously cached copy. To make it more clear:Assume the IIS Temporary Files folder is empty
<div mce_keep="true">Access a page using the virtual path provider</div>
<div mce_keep="true">Page gets compiled and cached with the custom cache dependency</div>
<div mce_keep="true">Further calls to the same page use the cached copy unless the cache dependency expired</div>
<div mce_keep="true">Restart the web server</div>
<div mce_keep="true">Access the page again</div>
<div mce_keep="true">Some machines do not retrieve a fresh copy of the page while others do.</div>
I tried invalidating my cache also when the cachedependency disposes but with no effect.
Is there any way to force the application to retrieve a fresh copy in this scenario?
Some machines do not retrieve a fresh copy of the page while others do.
It seems that the problem occurs when you restart your server and some of your client visitors cannot get a fresh copy of the page, right?
Is the cache caused by the browser of ASP.NET cache behavior, have you check the cache settings of those browsers? (Since not all clients face that issue)
Besides, as for ASP.NET side, I suggest that you can produce a random number while restarting your application and this number can be part of your variables which
used in custom cache dependency. (Application_Flag + YourCustomCacheDependencyFlag) So it force the client to get the fresh copy.
This has nothing to do with client-sde caching or output caching. This is the version of the form retrieved. I cannot assign a random number as I dont know which pages exist in the system plus the idea is to retrieve a new page only if a new version is published
or the server is restarted. By retrieving a new copy i mean how often VirtualFile.Open() is called.
Strange, I had replied to this right after I saw this post, but I don't see my reply here. GetFileHash() should not be based on the file
name, so that won't work. Instead, it should be based on the content of the file. If you have a last changed timestamp that makes an ideal choice for this.
Hope you can help me out here. Couldn't find a solution after hours of google searching.
I have written a custom virtual path provide which retrieves images/css from the sql server. Problem is caching seems to have stopped. Everytime the page is re-visited, it loads up all images/css again from the database.
Member
10 Points
38 Posts
Virtual Path Provider file retrieval
Nov 26, 2008 11:33 AM|Lambros Vasiliou|LINK
We have developed a Virtual Path Provider and a custom cachedependency for our aspx pages. Everything seems to be working just fine since we serve and invalidate aspx pages. The issue is that some machines retrieve a fresh copy of the form on first request while others reuse a previously cached copy. To make it more clear:Assume the IIS Temporary Files folder is empty
I tried invalidating my cache also when the cachedependency disposes but with no effect.
Is there any way to force the application to retrieve a fresh copy in this scenario?
Contributor
3384 Points
1363 Posts
Re: Virtual Path Provider file retrieval
Nov 26, 2008 11:53 AM|davidebb|LINK
Hi Lambros,
What does your VPP.GetFileHash() implementation look like? Are you getting various calls on your VPP in cases where you don't get a fresh copy?
David
Member
10 Points
38 Posts
Re: Virtual Path Provider file retrieval
Nov 26, 2008 12:06 PM|Lambros Vasiliou|LINK
David,
I am not overriding GetFileHash at all. Is it supposed to return: @"/forms/myform.aspx".GetHashCode().ToString(); ?
Lambros
All-Star
35458 Points
3430 Posts
Re: Virtual Path Provider file retrieval
Dec 01, 2008 10:38 PM|Nai-Dong Jin - MSFT|LINK
Hi,
It seems that the problem occurs when you restart your server and some of your client visitors cannot get a fresh copy of the page, right?
Is the cache caused by the browser of ASP.NET cache behavior, have you check the cache settings of those browsers? (Since not all clients face that issue)
Besides, as for ASP.NET side, I suggest that you can produce a random number while restarting your application and this number can be part of your variables which used in custom cache dependency. (Application_Flag + YourCustomCacheDependencyFlag) So it force the client to get the fresh copy.
Thanks.
Member
10 Points
38 Posts
Re: Virtual Path Provider file retrieval
Dec 02, 2008 07:58 AM|Lambros Vasiliou|LINK
Hello,
This has nothing to do with client-sde caching or output caching. This is the version of the form retrieved. I cannot assign a random number as I dont know which pages exist in the system plus the idea is to retrieve a new page only if a new version is published or the server is restarted. By retrieving a new copy i mean how often VirtualFile.Open() is called.
Contributor
3384 Points
1363 Posts
Re: Virtual Path Provider file retrieval
Dec 02, 2008 11:42 AM|davidebb|LINK
Strange, I had replied to this right after I saw this post, but I don't see my reply here. GetFileHash() should not be based on the file name, so that won't work. Instead, it should be based on the content of the file. If you have a last changed timestamp that makes an ideal choice for this.
thanks,
David
Member
10 Points
38 Posts
Re: Virtual Path Provider file retrieval
Dec 02, 2008 12:03 PM|Lambros Vasiliou|LINK
David,
Will GetFileHash() be called every time we hit the URL though? I want to avoid the roundtrip to my server unless I really have to.
Contributor
3384 Points
1363 Posts
Re: Virtual Path Provider file retrieval
Dec 02, 2008 12:37 PM|davidebb|LINK
No, I don't believe so, as long as the CacheDependency you return from GetCacheDependency remains valid. Let me know if you find otherwise.
David
Member
10 Points
38 Posts
Re: Virtual Path Provider file retrieval
Dec 05, 2008 09:54 AM|Lambros Vasiliou|LINK
David,
Thanks for your reply. I will give it a go and will let you know.
Regards,
Lambros
Member
10 Points
38 Posts
Re: Virtual Path Provider file retrieval
Dec 12, 2008 08:54 AM|Lambros Vasiliou|LINK
David,
That worked like a charm. GetFileHash is not called unless the cachepolicy is expired.
Thanks
Member
1 Points
9 Posts
Re: Virtual Path Provider file retrieval
Feb 26, 2010 07:40 PM|Webdeveloper_sim|LINK
Hi,oo
Hope you can help me out here. Couldn't find a solution after hours of google searching.
I have written a custom virtual path provide which retrieves images/css from the sql server. Problem is caching seems to have stopped. Everytime the page is re-visited, it loads up all images/css again from the database.
Please let me know if you could help.