问题
This is a follow-up to a previous question where the answer to "How do I ensure I see the latest JS code in my Task Pane add-in" involved controlling the client side caching behavior via server-added meta/no-cache tags (or versioning the server resources).
However, I am looking for a manual way, on the client, for the end-user to clear out the client side cache that appears to be storing JavaScript files and preventing an updated JS file on the server from being used by the Task Pane add-in. During development, I'll be updating the JS resources frequently on the server and I am looking for a client side solution that allows those updated files to be used.
Environment: Desktop version of Excel 2016 running on Mac (OSX 10.11.5) Task Pane add-in using v1.2 of the Excel/Office.js.
Scenario: deploy add-in artifacts to web server, run add-in on Mac. Then update code in foo.js in add-in, re-deploy to web server. Run add-in and see old (pre-update) behavior from foo.js.
What I have tried:
On the same Mac, loaded foo.js directly from the web app in Safari. I can see the changes in the js code that I expect to be in the updated version.
Cleared the Safari cache (Privacy > Remove All Website Data) (I suspected that this would not work based on #1 - Safari does not appear to share a cache with Excel but worth a shot) - did not change anything.
Poked around under ~/Library/Containers/com.microsoft.Excel trying to find a cache - deleted ~/Library/Containers/com.microsoft.Excel/Data/Library/Caches/com.microsoft.Excel - no help.
Used the Reload menu item from the Task Pane's context menu (looks like [i] on the Mac) - no difference: still seeing old foo.js.
Where are the JavaScript files referenced by an Excel (desktop) 2016 Task Pane add-in stored? (on the Mac) and how can the end user remove them?
回答1:
I stumbled upon com.Microsoft.OsfWebHost while poking around using the "defaults" command from a Terminal on the Mac. Some googling turned up this article which basically provided the answer. In a slight refinement to what is instructed there, this is what I did:
- ensured that I had quit Excel
- in Finder, navigated to ~/Library/Containers/com.Microsoft.OsfWebHost/Data/Library/Caches
- renamed (or deleted) the folder named "com.Microsoft.OsfWebHost" there
- opened my workbook in Excel (it already has the add-in Inserted)
- nothing seemed to be loading, so I used the Reload command from the context menu in the Task Pane
Now I could see that my updated version of the java script file has been loaded.
This is based on empirical evidence only, no corroboration from Microsoft or Apple doc, so your mileage may vary.
BTW, there are some interesting "defaults" properties for the com.Microsoft.OsfWebHost:
defaults read com.Microsoft.OsfWebHost
{
WebKitCacheModelPreferenceKey = 1;
WebKitDebugFullPageZoomPreferenceKey = 1;
WebKitPluginsEnabled = 0;
WebKitUsesPageCachePreferenceKey = 0;
}
Googling for WebKitCacheModelPreferenceKey did not turn up any official documentation, but there seem to be suggestions that setting it to 0 might suppress caching.
来源:https://stackoverflow.com/questions/38248350/how-to-clear-client-side-browser-cache-for-excel-2016-task-pane-add-in-on-mac