Stop OneNote (online) from caching my Add-In during development? - caching

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.

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

Related

What are all the new HTML document types in VS 2012 RC?

I just installed VS 2012 RC and in the HTML toolbar dropdown it has a bunch of new options:
DOCTYPE: HTML5
HTML5
XHTML5
What's the difference between the two HTML5 options? I thought the recommendation for HTML5 was not to specify a DOCTYPE, so the first option is kinda like "would you like some caffeine with that decaf?"
I was pretty sure that W3C abandoned XHTML in favor of evolving HTML, so what's this new XHTML5 option? Update: seems like Wikipedia had an answer for that.
Thanks in advance!
Update: posted a new question for the unanswered bits.
PS: I am not looking for an explanation of the purpose of the dropdown, but rather an explanation of what the difference is between choosing "DOCTYPE:HTML5" and "HTML5".
Regarding the HTML5 vs. DOCTYPE:HTML5 question, here's what I've observed while using VS 2012 RTM:
The DOCTYPE:{value} option tells VS to examine your page and attempt to figure out from the DOCTYPE and html tags what level of validation to apply. For example, if I create a page that begins as follows:
<!DOCTYPE html>
<html>
...
then the DOCTYPE:{value} option becomes DOCTYPE: HTML5. If, however, my page starts like this:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
...
then it becomes DOCTYPE: XHTML5.
The options that don't have the DOCTYPE: prefix force VS to use the selected level of validation regardless of what the structure/content of your page might suggest.
XHTML 5.0, usually written XHTML5, means HTML5 in XHTML serialization. Reference: HTML vs XHTML in the W3C HTML5 draft. So it’s HTML5 written using XML-conformant markup. Yes, the name “XHTML5” is odd and confusing, but it was probably selected for its assumed coolness factor.
All HTML5 drafts require the use of DOCTYPE preamble. See e.g. The DOCTYPE in W3C HTML5 draft. It’s not really a document type declaration even formally (there is no DTD for HTML5, and my attempts at writing one suggest that it would be rather problematic). Rather, it’s just a magic string that is to be used to make browsers apply “standards mode” vs. “quirks mode”. And it does this job well.
To see the difference between “DOCTYPE:HTML5” and “HTML5”, check out their effects on the source code of the result. My bet is that the latter mean HTML5 without DOCTYPE preamble, which is illogical, as HTML5 requires the preamble. If this is the case, “HTML5” throws browsers to “quirks mode”, which is normally bad for any new page, but often necessary for old pages if one wants to avoid major rewrite.

How to override firefox cache?

I'm using Firefox to view my applets, but when I make changes it's still the old version that Firefox is displaying. The only way I can change the version Firefox is showing me is by changing the names of the html AND the .class or jar files. Ctrl Shift R isn't working.
<meta http-equiv="Cache-control" content="no-cache" /> in the <head> tag should cause Firefox (or any browser for that matter) to not cache anything at all on that particular page.
Test applets in the appletviewer whenever possible. It does not cache classes.
For deployment, deploy them via JNLP whenever possible (user has Next Generation JRE) for more reliable class update.
Try linking it with myapplet.class?somerandomstring. Then the Browser thinks "maybe its generated dynamically, so i need to reload it". At least with images it works very well.
Ctrl+Shift+Del and then select cache checkbox with the interval you want to clear from the top of the window. Then click OK button.

IE Standards modes

I just have a quick question about IE8 Standards mode vs Quirks mode.
The page displays fine if you load its first page then log in. I have searched for the doc type which i think is right for changing the page to IE8 Standards Mode and i think it works because IE's built in debugger says it's in that mode. Also if you start on another page which uses quirks mode then navigate to my site the debugger changes modes to IE8 standards.
The problem starts if your change the mode to IE8 standards before you visit the page. e.g say your on google and change the mode in the debugger to IE8 standards then visit the site the page isn't displayed correctly.
I hope i've explained my problem clearly enough. I've posted the doctype i'm using is that is any help.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Add this meta tag to the head
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
This will force IE into the latest standards mode. So if they have IE8 it will be in IE8 even if its set before to other mode.
Also you could start using the html doctype without problem
<!DOCTYPE html>
You can read more about it here:
The IE Blog has posted "How IE8 Determines Document Mode" which you should read. Also, note that MS introduced a (... ah! Geries beat me to the punch while typing this!) Take a look at Geries' comment. :)

Mysterious cross-server display issue

I have a problem I haven't seen before. I am doing a realign on our company's website and am testing locally. However, when I upload to our test server I notice display discrepancies within the same browser (IE8)!
Here is a screenshot of the two pages, both viewed in IE8 but residing on different servers. In the page on the right, you can see there is a weird chunk of white space to the side underneath the .swf file.
Can anyone give any insight as to why the same page on distinct servers would look different in the same browser? I have also noticed a couple of other cross-server bugs within Firefox.
Thanks!
One possibility that comes to mind is IE8's compatibility mode. There is the X-UA-Compatible header directive that forces IE8 into compatibility mode or out of it. Maybe one of the servers sends out that information.
Try adding a compatibility mode directive to the header and see whether it has any effect:
<!-- Mimic Internet Explorer 7 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >
and alternatively:
<meta http-equiv="X-UA-Compatible" content="IE=100" > <!-- IE8 mode -->
Reference at MSDN: Defining Document Compatibility

why am I triggering quirks mode in IE8?

I'm working on a page that, when I load into IE8 and view the developers tools it tells me that page default is quirks mode.
I've got a strict DTD:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
I even went ahead and put in the explicit standards switch, though I didn't think I'd need to:
<meta http-equiv="X-UA-Compatible" content="IE=8" />
I can't understand why page default isn't IE8 standards?
Only thing I can think of is that to get to this page, I first have to log in to an application and the first pages I must traverse are old quirks mode pages. Does IE decide on which mode to use at a server level, or is it supposed to decide page by page?
Thanks!
Does IE decide on which mode to use at a server level
Not generally, no. There is the ugliness of the compatibility view list, which is site-specific, but that only kicks you back to IE7-style-Standards Mode, not IE5.5-style-Quirks-Mode.
Your code otherwise looks OK, as long as that DOCTYPE is the very first thing on the page. IE will be forced to document.compatMode= 'BackCompat' if there is a comment, PI, XML declaration (prior to IE8) or any non-whitespace textual content before the doctype. If a control character has snuck in that you can't see in your text editor, that could do it.
Example problem page?

Resources