1

I discovered an issue with Internet Explorer 9 and Internet Explorer 8 Comp (so far) with the jQuery plugin, jCryption. Calling the page the first time works fine in said IE version. Subsequent calls to the page result in only the handshake being called, while keypair generation is ignored. The problem is how these version of IE handle caching.

I looked at the source code of jCryption and here is the set of code which calls keypair generation:

/**
* Gets the data from the specified url, and converts it into a RSA keypair
* @param {string} url The URL to contact
* @param {string} data The JSON data
*/
$.getJSON(url, function(data) {
                var keys = new jCryptionKeyPair(data.e, data.n, data.maxdigits);
                if($.isFunction(callback)) {
                        callback.call(this, keys);
                }
        });

I changed it's request from GET to POST, which effectively disables caching of this request.

$.ajax({
        url: url,
        dataType: 'json',
        type: "POST",
        success: function(data) {
                         var keys = new jCryptionKeyPair(data.e, data.n, data.maxdigits);
                         if ($.isFunction(callback)) {
                                 callback.call(this, keys);
                         }
                 }
        });

The handshake code is similar, in that it also makes a jQuery Ajax POST request.

neubert
  • 15,947
  • 24
  • 120
  • 212
user717236
  • 4,959
  • 19
  • 66
  • 102
  • 1
    IE caches the results of AJAX calls. Try adding cache:false to the [`$.ajax`](http://api.jquery.com/jQuery.ajax/) calls. Also see http://stackoverflow.com/questions/4303829/how-to-prevent-jquery-ajax-caching-in-internet-explorer – andyb Oct 18 '12 at 15:26
  • Thank you for your help. I have tried using Cache-Control: no-cache, no-store and it did not work. Setting cache: false to the $.ajax call works, but I don't feel it's the most elegant, clean solution. The author of the jCryption uses an $.ajax call for the *handshake*. So, I modeled the above solution after his call. – user717236 Oct 18 '12 at 15:37

0 Answers0