MooTools Depender, Safari, etags and 412 Precondition Failed

/**
* This replaces the default MooTools more Depender.request function to use
* HTTP "get" rather than "post".
*
* When sending requests for files via the depender, I was finding that Safari
* wasn't getting and re-evaluating them the second time I visited the page.
* This was because an etag was sent with each script.
*
* Safari responds to etags properly and adds "If-None-Match" and
* "If-Modified-Since" headers to another request for the same file. This makes
* Apache respond with a 412 status (Precondition Failed) as it should do for
* "post" requests (according to RFC 2616).
*
* Unfortunately Safari doesn't then deal with the 412 as it does with a 304
* (Not Modified). It doesn't grab what it has in the cache and put it in the
* response, it gives you nothing.
*
* For "get" requests, Apache has to respond with a 304, or 200 or whatever, but
* not 412. So we change the request method so we don't have to deal with 412.
*/
Depender.request = function(url, callback){
    new Request.JSON({
        url: url,
        secure: false,
        onSuccess: callback,
        method:'get'
    }).send();
};

5 thoughts on “MooTools Depender, Safari, etags and 412 Precondition Failed

  1. Pingback: iOS 7 and 412 precondition failed | Looseideas

  2. Intriguing point of view. I’m curious to believe what type of impact this would have globally? Sometimes folks get a little upset with global expansion. I’ll be about soon to check out your response.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>