Programming, technology, and CRM – from a Belgian programmer exiled to Missouri
  • rss
  • Home
  • Soft Gallery
    • autosvnbackup.sh
    • VBScript Snippets
  • Contact Me
  • Welcome

Prevent Caching of Script Service AJAX calls – the lazy way

Nicolas Galler | February 20, 2008

“REST” style AJAX calls can be cached by the browser if the server is not properly configured. For some services this is a good thing (think, a mapping service), but often it is a hassle.

The way I see it there are 3 ways to get around it:

  • The “proper” way is to configure the caching on the server app. For example in ASP.NET use Response.Cache.SetCacheability(HttpCacheability.NoCache), or use the <%@ OutputCache %> tag.
  • The “fix it from the client” way is to add a random parameter to the Javascript. This way the query is different every time. If the server can accept POST as well as GET you can also use a POST since those are not cached.
  • The “lazy” way is to force a header from the server configuration. In IIS this is super easy:
    1. edit the properties of the directory that contains your script services
    2. go to HTTP Headers
    3. Add a custom header: name is “Cache-Control” and value is “no-cache”
Comments
No Comments »
Categories
Programming
Tags
AJAX, ASP.NET
Comments rss Comments rss
Trackback Trackback

Debug cross-domain request from local files in FireFox

Nicolas Galler | February 11, 2008

Lots of conflicting information on this one… Most pages will recommend using

netscape.security.PrivilegeManage.enablePrivilege("UniversalBrowserRead");
netscape.security.PrivilegeManage.enablePrivilege("UniversalBrowserRead");

Or go to about:config and toggle the setting for signed.applets.codebase_principal_support.
This didn’t do the trick for me, in fact it appears it is NOT required when you want to debug local files.
The only thing I had to do was create a file user.js under the FF profile directory (\D&S\user\App Data\Mozilla etc) with following content:

user_pref("capability.policy.XMLHttpRequestToAnySite.XMLHttpRequest.open", "allAccess");
user_pref("capability.policy.XMLHttpRequestToAnySite.sites", "http://localhost");
user_pref("capability.policy.XMLHttpRequestToAnySite.sites", "file://");
user_pref("capability.policy.policynames", "XMLHttpRequestToAnySite");

There is a security implication though. Any HTML file open from the hard drive will be able to communicate with any web site. Unfortunately I was not able to restrict the “file://” URL to a specific directory (like “file:///E:/html_projects” or something like that). Because of that I may have to keep coming back to this file and turn it off when I am done debugging. Or debug from the localhost server.

Comments
No Comments »
Categories
Programming
Tags
AJAX
Comments rss Comments rss
Trackback Trackback

Categories

  • Experiments (4)
  • Interesting (1)
  • MSCRM (1)
  • Programming (60)
  • Rant (3)
  • Saleslogix (34)
  • Tricks (8)
  • Uncategorized (30)

Post History

  • 2010
    • January (3)
    • March (3)
    • April (2)
    • August (2)
  • 2009
    • March (2)
    • April (1)
    • May (3)
    • June (3)
    • July (1)
    • September (3)
    • October (2)
    • December (5)
  • 2008
    • January (9)
    • February (4)
    • March (9)
    • April (1)
    • May (5)
    • June (8)
    • July (1)
    • August (2)
    • September (1)
    • November (1)
    • December (3)
  • 2007
    • January (3)
    • February (7)
    • March (1)
    • April (3)
    • May (6)
    • June (2)
    • July (1)
    • August (2)
    • September (5)
    • October (3)
    • November (5)
    • December (4)
  • 2006
    • January (2)
    • September (1)
    • November (3)
    • December (4)
  • 2005
    • April (1)

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox