web.onassar.com Archive

I can be reached at onassar@gmail.com.

For my open source work, check out github.com/onassar

Mootools caveat #2: noCache in new Request() is your friend

View more posts

Reading the docs is really worth it's weight in gold. Namely, noCache option/parameter for a new Request (aka. Ajax for MooTools) object really does make all the difference in the world.

"noCache - (boolean; defaults to false) If true, appends a unique noCache value to the request to prevent caching. (IE has a bad habit of caching ajax request values. Including this script and setting the noCache value to true will prevent it from caching. The server should ignore the noCache value.)"

I was having a problem with ajax being 'retrieved' by IE, but not actually making a hit in my access log. I was baffled, and figured it was a caching issue, but confused since safari/FF were working fine.

For those of you out there, be aware of this. My specific problem was actually based on a call to something like:


Now I can make that exact url call and have it return a bunch of html; but for the framework I'm working in, adding a header of AC:true (short form for 'Ajax Call') will change the output (namely, to a JSON object instead of pure html). It seems IE was caching the request since the page had been requested without the header, and then returning it every time.

Damn you IE!!!!! I understand <link />, <script /> and <img /> tags being cached, but XHRs? Come on. They're based on actions (eg. click events, mouse overs, key combinations), not default behaviours of a page load (ordinarily).