In my system I frequently require data by Ajax requests. For example, different lists, content of modal dialogs, etc. This data can't be changed after request, so I wrote cache mechanism which stores Ajax result and then before Ajax request checks is there stored data.Here is example:YFeX.cache = { }; // YFex is my own namespace$('#account_modal_button').click(function () {    if (YFeX.cache.account_modal !== undefined) {        YFeX.modal(YFeX.cache.account_modal.title, YFeX.cache.account_modal.body);    } else {        $.ajax({            type:'GET',            url:'/?/login',            dataType:'json',            context:$(this),            success:function (data) {                YFeX.cache.account_modal = data.modal;                // YFeX.modal will be called automatically            }        });    }    return false;});Are there any 'bad' parts in my solution?
Simple cache mechanism?
javascript;jquery;ajax;cache
From a once over;Unless YFeX is also a constructor, it should be yFexlowerCamelCase is good for you: account_modal -> accountModalI would store YFeX.cache.account_modal into a var cachedAccountModal so that you do not have to repeat YFeX.cache.account_modal all the timeYour code is very optimistic, you should also deal with failConsider using the shorthand $.get()Other than that, the code looks fine to me.