Cache Prevention for Dojo xhr requests


/**
 * Cache Prevention for Dojo xhr requests
 *
 * Adds no-cache header and enables dojo's preventCache feature
 * for every dojo xhr call. This prevents the caching of partial
 * refreshs.
 *
 * @author Sven Hasselbach
 * @version 0.3
 *
 **/
dojo.addOnLoad(
    function(){
        if( !dojo._xhr )
        dojo._xhr = dojo.xhr;
        
        dojo.xhr = function(){        
            try{
                var args = arguments[1];   
                args["preventCache"] = true;
                args["headers"] = { "cache-control": "no-cache" };
                arguments[1] = args;
        	}catch(e){}
        	
        	dojo._xhr( arguments[0], arguments[1], arguments[2] );
        }
    }
)
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
1 comment(s)Login first to comment...
Panu Haaramo
(at 06:28 on 28.01.2013)
Using this breaks the DataGrid: http://stackoverflow.com/questions/14519695/disable-cache-in-extlib-rest-control-which-uses-dojox-data-jsonreststore