3

For god knows what reason, Office Add-ins on my local word client is Caching a html file that I dynamically load in (through angular) and refuses to give me a way to remove it from the cache. My only solution is to rename the file and force it to look for a new one.

I know it's a caching issue and not a code issue because when I load the app up inside the web-client it always gets the new version and not the old version.

Please help, renaming files every time I change them is stupid and time consuming

Kim Brandl
  • 11,964
  • 2
  • 14
  • 19
Michael Crook
  • 1,390
  • 2
  • 13
  • 37
  • Are you serving caching headers? If so, what are they set to? – Gab Royer Dec 09 '15 at 01:09
  • not that I am aware of. Can you even do that with office add-ins? – Michael Crook Dec 09 '15 at 01:15
  • Well, your HTTP server is the one returning the caching headers and the web frame that runs the add-in should in theory honor them. You should be able to see them using Fiddler. – Gab Royer Dec 09 '15 at 01:44
  • Adding a 'Cache-Control' header on GET requests as in this [answer](http://stackoverflow.com/questions/16098430/angular-ie-caching-issue-for-http) got me round this problem for debugging in VS without caching AngularJS views and templates. – JayChase Feb 26 '16 at 11:30

4 Answers4

5

I had the same, not with Angular but JS add office add ins, cut off my webserver and still was able to load the HTML! For me what worked was the "Clear" button under Trust Centre -> Trusted Add-in catalogues. Perhaps this is HTML5 - something to do with you manifest, something like this in your HTML, or the equivalent automatically occurring?

`<html.... manifest="/manifest.appcache">

There are loads of suggestion for how to prevent this I haven't tried it yet, but this looks like it contains reasonable examples to test - if imparted in an unusual manner! http://alistapart.com/article/application-cache-is-a-douchebag

Second option which is now working a treat for me!

In internet Explorer go to Internet Options -> General tab -> Settings -> Temporary Internet files -> tick "Every time I visit the webpage". Naturally this only works for locally hosted sideloading apps.

Oddly enough IE seems to be the object loaded in Office 2016, not Edge, although I have had an Edge message appear in my side-load space, I'll try and grab a shot of it next time I see it (it was during an error it appeared!).

There are a few tricks that might work like this:

What does appending "?v=1" to CSS and Javascript URLs in link and script tags do?

Or in CSS like this:

https://css-tricks.com/can-we-prevent-css-caching/

Community
  • 1
  • 1
Jerry Weeks
  • 187
  • 1
  • 13
  • Have you tried the "Clear" button in Trust Centre then @veljasije? As I said it works for me, but there are possible differences with Angluar and JS, so unless I have access to the Angluar set up I cannot say for certain if "Clear" will work or not. What is almost certain is that this is caused by caching - so the suggestions in the URL I provided may also offer a more permanent solution. I could simply copy the advice over! – Jerry Weeks Mar 26 '16 at 14:38
  • where is the Trust Center? – Hao XU Jul 15 '20 at 08:34
1

Today (Win 10 1903 and newest Office 2016) Office AddIns are using Edge as WebViewHost. The WebViewHost seems to store the cached files here:

dir /s %LOCALAPPDATA%\Packages\Microsoft.Win32WebViewHost_cw5n1h2txyewy\AC\#!123\INetCache\

In our case we are using Azure App Service (IIS) as backend for our Office AddIn. And we added the following web.config setting to let the client re-validate all cached files on each access:

...
  <system.webServer>
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="0.00:00:00" cacheControlCustom="must-revalidate" />
    </staticContent>
...

Of course, the cacheControlMaxAge may be adjusted to your needs.

ndee
  • 346
  • 2
  • 12
1

Hitting Ctrl + Shift + F5 helped for me.

RobC
  • 16,905
  • 14
  • 51
  • 62
ChristophA
  • 11
  • 1
0

An easy workaround for this would be to append some random query string at the end of the url, thus making sure your browser has a cache miss.

For example, instead of getting the file http://myaddin/myfile.html, append a big enough random query string parameter so that you instead query for http://myaddin/myfile.html?cache=s98sj398nf03984jf3498n.

Gabriel Royer - Developer on the Office Extensibility Team, MSFT

Gab Royer
  • 8,876
  • 7
  • 36
  • 58