mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
parent
ccbe3bea79
commit
e06a206131
@ -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)
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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",
|
||||||
|
@ -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) {
|
||||||
|
@ -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({
|
||||||
|
@ -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);
|
||||||
|
@ -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));
|
||||||
|
@ -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);
|
||||||
|
@ -524,14 +524,11 @@ 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)) {
|
if (!this.get("stream.filter") && !this.inAllStream(ua)) {
|
||||||
@ -543,8 +540,7 @@ const User = RestModel.extend({
|
|||||||
stream.set("itemsLoaded", stream.get("itemsLoaded") + 1);
|
stream.set("itemsLoaded", stream.get("itemsLoaded") + 1);
|
||||||
stream.get("content").insertAt(0, action[0]);
|
stream.get("content").insertAt(0, action[0]);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
inAllStream(ua) {
|
inAllStream(ua) {
|
||||||
|
@ -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,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -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) => {
|
||||||
|
@ -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,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user