1

I'm having an annoying problem with OneNote (online) caching my Add-In. I'm sideloading my add-in and despite pushing a new build to my server, and doing a full refresh of the OneNote web page and re-inserting my Add-In, I still see the old add-in content. If I open a new tab using the Add-In URL found in my Add-In manifest, then I do see the new content so I'm almost certain it's a caching problem. In other words, I see the old content in the Add-In IFRAME provided by OneNote, but I see the new content if I load the same web page into a completely new tab.

Is there a setting or something I can do to defeat Add-In caching while I'm developing my Add-In?

NOTE: While we wait for a better answer, for now I am using the old trick of changing the Add-In URL in the manifest by adding a benign URL argument to the end of the URL that I increment with each version change. Hopefully someone will provide a better solution than this since it's a bit of a pain, but at least it's something for now.

Philip Rueker
  • 948
  • 5
  • 15
Robert Oschler
  • 14,153
  • 18
  • 94
  • 227

1 Answers1

2

It's not really OneNote Online that is caching your add-in - it's your browser.

Use the following HTML headers to prevent caching:

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>

Prevent caching of HTML page

In order to prevent caching of your JS, you might have to do more. I suggest appending a random number to your JS reference, as suggested here.

<script language="JavaScript">
    var s=document.getElementsByTagName('script')[0];
    var sc=document.createElement('script');
    sc.type='text/javascript';
    sc.async=true;
    sc.src='http://PATHTOYOURSCRIPT.js?v' + Math.random(); 
    s.parentNode.insertBefore(sc,s);
</script>

Preventing Cache on JavaScript files

Community
  • 1
  • 1
Jorge Aguirre
  • 2,787
  • 3
  • 20
  • 27