locked
Virtual Path Provider file retrieval RRS feed

  • Question

  • User749047830 posted

    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

    1. Access a page using the virtual path provider
    2. Page gets compiled and cached with the custom cache dependency
    3. Further calls to the same page use the cached copy unless the cache dependency expired
    4. Restart the web server
    5. Access the page again
    6. Some machines do not retrieve a fresh copy of the page while others do.

    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?

    Wednesday, November 26, 2008 11:33 AM

Answers

  • User1641955678 posted

    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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 2, 2008 11:42 AM

All replies

  • User1641955678 posted

    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

    Wednesday, November 26, 2008 11:53 AM
  • User749047830 posted

    David,

    I am not overriding GetFileHash at all. Is it supposed to return: @"/forms/myform.aspx".GetHashCode().ToString(); ?

    Lambros

    Wednesday, November 26, 2008 12:06 PM
  • User-1136466523 posted

    Hi,

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>

    Restart the web server

    Access the page again

    Some machines do not retrieve a fresh copy of the page while others do.

    <o:p> </o:p>

    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?

    <o:p> </o:p>

    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)

    <o:p> </o:p>

    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.

    <o:p> </o:p>

    Thanks.

     

    Monday, December 1, 2008 10:38 PM
  • User749047830 posted

    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.

    Tuesday, December 2, 2008 7:58 AM
  • User1641955678 posted

    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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 2, 2008 11:42 AM
  • User749047830 posted

     

    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.

    Tuesday, December 2, 2008 12:03 PM
  • User1641955678 posted

    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

    Tuesday, December 2, 2008 12:37 PM
  • User749047830 posted

    David,

    Thanks for your reply. I will give it a go and will let you know.

    Regards,

    Lambros

    Friday, December 5, 2008 9:54 AM
  • User749047830 posted

    David,

    That worked like a charm. GetFileHash is not called unless the cachepolicy is expired.

    Thanks

    Friday, December 12, 2008 8:54 AM
  • User-624976458 posted

    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.

    Friday, February 26, 2010 7:40 PM