More in this section

Forums / Developing with Sitefinity / Clear Designer JavaScript Cache Programatically

Clear Designer JavaScript Cache Programatically

5 posts, 0 answered
  1. kasun
    kasun avatar
    2 posts
    Registered:
    23 Mar 2015
    06 Sep
    Link to this post

    Hello, 

    I'm trying to find a way to clear the browser cache of all the "designerview-simple.js" files for the MVC widgets that we are building. 

    The only solution we came up with to attach a unique query string to the end of the js file so when the file get attached to the document browser will recognize the file as a new file and download a fresh copy of it.  

    Here is the code : 

    @Html.Script(Url.WidgetContent("Mvc/Scripts/mywidget/mywidgetview.js?version=" +VersionNumber), "top", false)

     

    Now we want to implement the same functionality to the "designerview-simple.js" .

    However we are not able to locate where the "designerview-simple.js" loading from or how its loaded , so we can add this code and the cache will be clear. 

    OR 

    Is there a better solution for this issues ? 

    Please let us know.

    Thank you in Advance 

    Kasun Peiris

     

  2. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    13 Sep in reply to kasun
    Link to this post
    Are you having issues with javascript files not loading the correct versions?
  3. kasun
    kasun avatar
    2 posts
    Registered:
    23 Mar 2015
    13 Sep in reply to Jonathan
    Link to this post
    Js files are loading but they are cached. Im not able to add a version number to the end of the file url as I don't know where are they loading. 
  4. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    26 Sep
    Link to this post

    Have you taken a look at this article.  I believe the concepts can be applied to the issue you have.

     

    http://www.sitefinity.com/blogs/peter-filipov-blog/2017/09/18/solving-caching-issues-in-the-sitefinity-mvc-navigation-widget 

  5. Clinton
    Clinton avatar
    14 posts
    Registered:
    27 Feb 2014
    29 Sep in reply to Jonathan
    Link to this post

    Hi Jonathan,

    I think what Kasun wants here is a way to force invalidate the client-side cache. The article you linked is for invalidating server-side cache.

    Our browsers cache specific URLs based on their name, this is why in Kasun's example above he adds the version number to the URL to force the browser into retrieving a fresh copy of the file. This version number will increase based on the changes he makes to the file.

    Is there any way to append a query string to the URL of the designerview-simple.js so the browser is forced to download a new copy? Similar to that of the jQuery Ajax "cache" property that adds a query string value "_" set to the current time stamp.

    Let us know!

    Regards,
    Clinton

5 posts, 0 answered