Globally prevent AJAX requests from being cached

This commit is contained in:
Rouslan Placella 2011-12-19 20:16:54 +00:00
parent 8b064f0790
commit 0d7b3a5877
7 changed files with 14 additions and 51 deletions

View File

@ -95,14 +95,6 @@ function deleteResult(result_path, msg, ajaxEnable)
}
$(document).ready(function() {
/**
* Set a parameter for all Ajax queries made on this page.
* Don't let the web server serve cached pages
*/
$.ajaxSetup({
cache: 'false'
});
/** Hide the table link in the initial search result */
var icon = PMA_getImage('s_tbl.png', '', {'id': 'table-image'}).toString();
$("#table-info").prepend(icon).hide();

View File

@ -1,6 +1,6 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* general function, usally for data manipulation pages
* general function, usually for data manipulation pages
*
*/
@ -43,6 +43,19 @@ function getWindowSize(wnd) {
};
}
/**
* Make sure that ajax requests will not be cached
* by appending a random variable to their parameters
*/
$.ajaxPrefilter(function (options, originalOptions, jqXHR) {
var nocache = new Date().getTime() + "" + Math.floor(Math.random() * 1000000);
if (typeof options.data == "string") {
options.data += "&_nocache=" + nocache;
} else if (typeof options.data == "object") {
options.data = $.extend(originalOptions.data, {'_nocache':nocache});
}
});
/**
* Add a hidden field to the form to indicate that this will be an
* Ajax request (only if this hidden field does not exist)

View File

@ -139,17 +139,6 @@ function appendNewUser(new_user_string, new_user_initial, new_user_initial_strin
*/
$(document).ready(function() {
/** @lends jQuery */
/**
* Set a parameter for all Ajax queries made on this page. Some queries
* are affected by cache settings on the server side, and hence, show stale
* data. Don't let the web server serve cached pages
*/
$.ajaxSetup({
cache: 'false'
});
/**
* AJAX event handler for 'Add a New User'
*

View File

@ -8,10 +8,6 @@ $(function() {
saveLink = '<a href="#" class="saveLink">' + PMA_getImage('b_save.png') + ' ' + PMA_messages['strSave'] + '</a> ';
cancelLink = '<a href="#" class="cancelLink">' + PMA_getImage('b_close.png') + ' ' + PMA_messages['strCancel'] + '</a> ';
$.ajaxSetup({
cache:false
});
/* Variable editing */
if (is_superuser) {
$('table.data tbody tr td:nth-child(2)').hover(

View File

@ -72,15 +72,6 @@ function getFieldName($this_field)
* @memberOf jQuery
*/
$(document).ready(function() {
/**
* Set a parameter for all Ajax queries made on this page. Don't let the
* web server serve cached pages
*/
$.ajaxSetup({
cache: 'false'
});
/* Hides the bookmarkoptions checkboxes when the bookmark label is empty */
$('input#bkm_label').keyup(function() {
$('input#id_bkm_all_users, input#id_bkm_replace')

View File

@ -13,15 +13,6 @@
* Table Search
*/
$(document).ready(function() {
/**
* Set a parameter for all Ajax queries made on this page. Don't let the
* web server serve cached pages
*/
$.ajaxSetup({
cache: 'false'
});
/**
* Prepare a div containing a link, otherwise it's incorrectly displayed
* after a couple of clicks

View File

@ -167,15 +167,6 @@ function includePan(currentChart) {
}
$(document).ready(function() {
/**
** Set a parameter for all Ajax queries made on this page. Don't let the
** web server serve cached pages
**/
$.ajaxSetup({
cache: 'false'
});
var cursorMode = ($("input[name='mode']:checked").val() == 'edit') ? 'crosshair' : 'pointer';
var currentChart = null;
var currentData = null;