locked
JSLink caching issue resolution? RRS feed

  • Question

  • I am attaching several js files to the listform webpart property JSLink. They are seperated by the pipe (|) character. The scripts work fine. But everytime I make a change to the js file, I have to do CTRL+F5 to see the changes. This is not a viable solution where lets says that we deploy a Phase 2 of a project which is used by customers. After the Phase 2 deployment, customer still sees the old form ui and has to press CTRL+F5 once in the listforms to see the changes. This would work for one or two customers but not in the case of 100 odd users, asking them to do CTRL+F5. 

    My scripts are stored in SiteAssets library. I have read that adding a timestamp to the end of the js file would cause it to refresh every time the page is loaded. But I tried that and it does not work  (~sitecollection/mysite/siteassets/foo1.js?ts=new Date.getTime()|~sitecollection/mysite/siteassets/foo2.js?ts=new Date.getTime()). 

    The only other thing to make it work was to do iis reset. But this may not be an acceptable solution in production where business users are working on different sites and experience loss of data.

    Kindly do let me know how to resolve this?

    Wednesday, June 15, 2016 10:11 AM

Answers

  • Hi,

    Please add the version in querystring like this:

    ~sitecollection/mysite/siteassets/foo1.js?1.0.0.0|~sitecollection/mysite/siteassets/foo2.js?1.0.0.0

    When you modify the foo1.js or foo2.js file, please modify the list form web part and change the JSLink as below:

    ~sitecollection/mysite/siteassets/foo1.js?1.0.0.1|~sitecollection/mysite/siteassets/foo2.js?1.0.0.1

    The "ts=new Date.getTime()" not work in jslink, you can see the source code(right click in IE).

    Best Regards,

    Dennis


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    • Proposed as answer by Patrick_Liang Thursday, June 23, 2016 9:15 AM
    • Marked as answer by Patrick_Liang Thursday, June 30, 2016 9:02 AM
    Thursday, June 16, 2016 7:50 AM
  • Hi Dennis,

    I ended up creating a folder called JS and renaming that folder for every release ,i.e., JSRel1,JSRel2,etc and then updating that path in JSLink for every release

    • Marked as answer by Dennis Guo Friday, July 8, 2016 1:25 AM
    Thursday, July 7, 2016 9:52 AM

All replies

  • Hi Sanjuv,

    I don't think we can force browser to clear cache what we can do is to tell browser that new version of JS is available and take that version.

    Check below links for JS version solution.

    http://stackoverflow.com/questions/32414/how-can-i-force-clients-to-refresh-javascript-files

    http://stackoverflow.com/questions/16331443/how-to-tell-the-browser-to-remove-a-file-from-the-cache-and-get-the-newly-deploy

    Wednesday, June 15, 2016 11:27 AM
  • Hi Jaydev,

    Thanks for the reply. I checked your links but they all talk about adding a querystring with a value like v=1 or crc=ADBSDF  or rev=1.0.3 or adding the datetime. As you can see , I have tried adding datetime to JSLink but it does not work.

    ~sitecollection/mysite/siteassets/foo1.js?ts=new Date.getTime()|~sitecollection/mysite/siteassets/foo2.js?ts=new Date.getTime()

    Thursday, June 16, 2016 6:58 AM
  • Hi,

    Please add the version in querystring like this:

    ~sitecollection/mysite/siteassets/foo1.js?1.0.0.0|~sitecollection/mysite/siteassets/foo2.js?1.0.0.0

    When you modify the foo1.js or foo2.js file, please modify the list form web part and change the JSLink as below:

    ~sitecollection/mysite/siteassets/foo1.js?1.0.0.1|~sitecollection/mysite/siteassets/foo2.js?1.0.0.1

    The "ts=new Date.getTime()" not work in jslink, you can see the source code(right click in IE).

    Best Regards,

    Dennis


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    • Proposed as answer by Patrick_Liang Thursday, June 23, 2016 9:15 AM
    • Marked as answer by Patrick_Liang Thursday, June 30, 2016 9:02 AM
    Thursday, June 16, 2016 7:50 AM
  • Hi Dennis,

    I ended up creating a folder called JS and renaming that folder for every release ,i.e., JSRel1,JSRel2,etc and then updating that path in JSLink for every release

    • Marked as answer by Dennis Guo Friday, July 8, 2016 1:25 AM
    Thursday, July 7, 2016 9:52 AM