DEV: Remove cache option from ajax() (#13142)

1. It defaults to `cache: true` already
2. Setting it to `false` for non-GET request doesn't do anything
3. We were correcting `cache: false` GET requests to use `cache: true`

…so setting it to anything at all, for any type of request doesn't make sense (anymore)
This commit is contained in:
Jarek Radosz 2021-05-31 14:41:35 +02:00 committed by GitHub
parent ccbe3bea79
commit e06a206131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 23 additions and 44 deletions

View File

@ -366,7 +366,7 @@ export default Component.extend({
}, },
_buildPayload(facets) { _buildPayload(facets) {
let payload = { data: { cache: true, facets } }; let payload = { data: { facets } };
if (this.startDate) { if (this.startDate) {
payload.data.start_date = moment(this.startDate) payload.data.start_date = moment(this.startDate)

View File

@ -162,10 +162,6 @@ export function ajax() {
args.headers["Discourse-Script"] = true; args.headers["Discourse-Script"] = true;
} }
if (args.type === "GET" && args.cache !== true) {
args.cache = true; // Disable JQuery cache busting param, which was created to deal with IE8
}
ajaxObj = $.ajax(getURL(url), args); ajaxObj = $.ajax(getURL(url), args);
} }

View File

@ -33,7 +33,6 @@ function searchTags(term, categories, limit) {
function () { function () {
oldSearch = $.ajax(getURL("/tags/filter/search"), { oldSearch = $.ajax(getURL("/tags/filter/search"), {
type: "GET", type: "GET",
cache: true,
data: { limit: limit, q }, data: { limit: limit, q },
}); });

View File

@ -99,7 +99,6 @@ export default function loadScript(url, opts) {
ajax({ ajax({
url: fullUrl, url: fullUrl,
dataType: "text", dataType: "text",
cache: true,
}).then(cb); }).then(cb);
} else { } else {
// Always load JavaScript with script tag to avoid Content Security Policy inline violations // Always load JavaScript with script tag to avoid Content Security Policy inline violations

View File

@ -156,7 +156,6 @@ export default class {
ajax("/topics/timings", { ajax("/topics/timings", {
data, data,
cache: false,
type: "POST", type: "POST",
headers: { headers: {
"X-SILENCE-LOGGER": "true", "X-SILENCE-LOGGER": "true",

View File

@ -141,7 +141,7 @@ const Bookmark = RestModel.extend({
url += "?" + $.param(params); url += "?" + $.param(params);
} }
return ajax(url, { cache: "false" }); return ajax(url);
}, },
loadMore(additionalParams) { loadMore(additionalParams) {

View File

@ -172,7 +172,6 @@ const Post = RestModel.extend({
return ajax(`/posts/${this.id}/recover`, { return ajax(`/posts/${this.id}/recover`, {
type: "PUT", type: "PUT",
cache: false,
}) })
.then((data) => { .then((data) => {
this.setProperties({ this.setProperties({

View File

@ -66,7 +66,7 @@ export default RestModel.extend({
this.set("loading", true); this.set("loading", true);
return ajax(findUrl, { cache: "false" }) return ajax(findUrl)
.then((result) => { .then((result) => {
if (result && result.no_results_help) { if (result && result.no_results_help) {
this.set("noContentHelp", result.no_results_help); this.set("noContentHelp", result.no_results_help);

View File

@ -50,7 +50,7 @@ export default EmberObject.extend({
this.set("loading", true); this.set("loading", true);
return ajax(this.url, { cache: false }) return ajax(this.url)
.then((result) => { .then((result) => {
if (result) { if (result) {
const posts = result.map((post) => UserAction.create(post)); const posts = result.map((post) => UserAction.create(post));

View File

@ -100,7 +100,7 @@ export default RestModel.extend({
} }
this.set("loading", true); this.set("loading", true);
return ajax(findUrl, { cache: "false" }) return ajax(findUrl)
.then((result) => { .then((result) => {
if (result && result.no_results_help) { if (result && result.no_results_help) {
this.set("noContentHelp", result.no_results_help); this.set("noContentHelp", result.no_results_help);

View File

@ -524,27 +524,23 @@ const User = RestModel.extend({
loadUserAction(id) { loadUserAction(id) {
const stream = this.stream; const stream = this.stream;
return ajax(`/user_actions/${id}.json`, { cache: "false" }).then( return ajax(`/user_actions/${id}.json`).then((result) => {
(result) => { if (result && result.user_action) {
if (result && result.user_action) { const ua = result.user_action;
const ua = result.user_action;
if ( if ((this.get("stream.filter") || ua.action_type) !== ua.action_type) {
(this.get("stream.filter") || ua.action_type) !== ua.action_type return;
) {
return;
}
if (!this.get("stream.filter") && !this.inAllStream(ua)) {
return;
}
ua.title = emojiUnescape(escapeExpression(ua.title));
const action = UserAction.collapseStream([UserAction.create(ua)]);
stream.set("itemsLoaded", stream.get("itemsLoaded") + 1);
stream.get("content").insertAt(0, action[0]);
} }
if (!this.get("stream.filter") && !this.inAllStream(ua)) {
return;
}
ua.title = emojiUnescape(escapeExpression(ua.title));
const action = UserAction.collapseStream([UserAction.create(ua)]);
stream.set("itemsLoaded", stream.get("itemsLoaded") + 1);
stream.get("content").insertAt(0, action[0]);
} }
); });
}, },
inAllStream(ua) { inAllStream(ua) {

View File

@ -29,7 +29,6 @@ function reportToLogster(name, error) {
Ember.$.ajax(getURL("/logs/report_js_error"), { Ember.$.ajax(getURL("/logs/report_js_error"), {
data, data,
type: "POST", type: "POST",
cache: false,
}); });
} }

View File

@ -63,24 +63,18 @@ createWidgetFrom(QuickAccessPanel, "quick-access-bookmarks", {
}, },
loadBookmarksWithReminders() { loadBookmarksWithReminders() {
return ajax(`/u/${this.currentUser.username}/bookmarks.json`, { return ajax(`/u/${this.currentUser.username}/bookmarks.json`).then(
cache: "false", ({ user_bookmark_list }) => user_bookmark_list.bookmarks
}).then((result) => { );
result = result.user_bookmark_list;
return result.bookmarks;
});
}, },
loadUserActivityBookmarks() { loadUserActivityBookmarks() {
return ajax("/user_actions.json", { return ajax("/user_actions.json", {
cache: "false",
data: { data: {
username: this.currentUser.username, username: this.currentUser.username,
filter: UserAction.TYPES.bookmarks, filter: UserAction.TYPES.bookmarks,
no_results_help_key: "user_activity.no_bookmarks", no_results_help_key: "user_activity.no_bookmarks",
}, },
}).then(({ user_actions }) => { }).then(({ user_actions }) => user_actions);
return user_actions;
});
}, },
}); });

View File

@ -71,7 +71,6 @@ function loadNext(ajax) {
category_id: categoryId, category_id: categoryId,
topic_id: topicId, topic_id: topicId,
}, },
cache: true,
}) })
.then( .then(
(html) => { (html) => {

View File

@ -11,7 +11,6 @@ export default Mixin.create({
searchTags(url, data, callback) { searchTags(url, data, callback) {
return ajax(getURL(url), { return ajax(getURL(url), {
quietMillis: 200, quietMillis: 200,
cache: true,
dataType: "json", dataType: "json",
data, data,
}) })