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

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)

diff --git a/app/assets/javascripts/admin/addon/components/admin-report.js b/app/assets/javascripts/admin/addon/components/admin-report.js
index 3ecf004..2fe0ab6 100644
--- a/app/assets/javascripts/admin/addon/components/admin-report.js
+++ b/app/assets/javascripts/admin/addon/components/admin-report.js
@@ -366,7 +366,7 @@ export default Component.extend({
   },
 
   _buildPayload(facets) {
-    let payload = { data: { cache: true, facets } };
+    let payload = { data: { facets } };
 
     if (this.startDate) {
       payload.data.start_date = moment(this.startDate)
diff --git a/app/assets/javascripts/discourse/app/lib/ajax.js b/app/assets/javascripts/discourse/app/lib/ajax.js
index b7be9db..a47ed55 100644
--- a/app/assets/javascripts/discourse/app/lib/ajax.js
+++ b/app/assets/javascripts/discourse/app/lib/ajax.js
@@ -162,10 +162,6 @@ export function ajax() {
       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);
   }
 
diff --git a/app/assets/javascripts/discourse/app/lib/category-tag-search.js b/app/assets/javascripts/discourse/app/lib/category-tag-search.js
index ef84ac8..eba355a 100644
--- a/app/assets/javascripts/discourse/app/lib/category-tag-search.js
+++ b/app/assets/javascripts/discourse/app/lib/category-tag-search.js
@@ -33,7 +33,6 @@ function searchTags(term, categories, limit) {
         function () {
           oldSearch = $.ajax(getURL("/tags/filter/search"), {
             type: "GET",
-            cache: true,
             data: { limit: limit, q },
           });
 
diff --git a/app/assets/javascripts/discourse/app/lib/load-script.js b/app/assets/javascripts/discourse/app/lib/load-script.js
index 9eebebf..7966e41 100644
--- a/app/assets/javascripts/discourse/app/lib/load-script.js
+++ b/app/assets/javascripts/discourse/app/lib/load-script.js
@@ -99,7 +99,6 @@ export default function loadScript(url, opts) {
       ajax({
         url: fullUrl,
         dataType: "text",
-        cache: true,
       }).then(cb);
     } else {
       // Always load JavaScript with script tag to avoid Content Security Policy inline violations
diff --git a/app/assets/javascripts/discourse/app/lib/screen-track.js b/app/assets/javascripts/discourse/app/lib/screen-track.js
index 0e17697..3391c8c 100644
--- a/app/assets/javascripts/discourse/app/lib/screen-track.js
+++ b/app/assets/javascripts/discourse/app/lib/screen-track.js
@@ -156,7 +156,6 @@ export default class {
 
     ajax("/topics/timings", {
       data,
-      cache: false,
       type: "POST",
       headers: {
         "X-SILENCE-LOGGER": "true",
diff --git a/app/assets/javascripts/discourse/app/models/bookmark.js b/app/assets/javascripts/discourse/app/models/bookmark.js
index b18402d..208dcdb 100644
--- a/app/assets/javascripts/discourse/app/models/bookmark.js
+++ b/app/assets/javascripts/discourse/app/models/bookmark.js
@@ -141,7 +141,7 @@ const Bookmark = RestModel.extend({
       url += "?" + $.param(params);
     }
 
-    return ajax(url, { cache: "false" });
+    return ajax(url);
   },
 
   loadMore(additionalParams) {
diff --git a/app/assets/javascripts/discourse/app/models/post.js b/app/assets/javascripts/discourse/app/models/post.js
index 610fa3d..5da002a 100644
--- a/app/assets/javascripts/discourse/app/models/post.js
+++ b/app/assets/javascripts/discourse/app/models/post.js
@@ -172,7 +172,6 @@ const Post = RestModel.extend({
 
     return ajax(`/posts/${this.id}/recover`, {
       type: "PUT",
-      cache: false,
     })
       .then((data) => {
         this.setProperties({
diff --git a/app/assets/javascripts/discourse/app/models/user-drafts-stream.js b/app/assets/javascripts/discourse/app/models/user-drafts-stream.js
index 90864e1..e703e5a 100644
--- a/app/assets/javascripts/discourse/app/models/user-drafts-stream.js
+++ b/app/assets/javascripts/discourse/app/models/user-drafts-stream.js
@@ -66,7 +66,7 @@ export default RestModel.extend({
 
     this.set("loading", true);
 
-    return ajax(findUrl, { cache: "false" })
+    return ajax(findUrl)
       .then((result) => {
         if (result && result.no_results_help) {
           this.set("noContentHelp", result.no_results_help);
diff --git a/app/assets/javascripts/discourse/app/models/user-posts-stream.js b/app/assets/javascripts/discourse/app/models/user-posts-stream.js
index b152630..53f48c9 100644
--- a/app/assets/javascripts/discourse/app/models/user-posts-stream.js
+++ b/app/assets/javascripts/discourse/app/models/user-posts-stream.js
@@ -50,7 +50,7 @@ export default EmberObject.extend({
 
     this.set("loading", true);
 
-    return ajax(this.url, { cache: false })
+    return ajax(this.url)
       .then((result) => {
         if (result) {
           const posts = result.map((post) => UserAction.create(post));
diff --git a/app/assets/javascripts/discourse/app/models/user-stream.js b/app/assets/javascripts/discourse/app/models/user-stream.js
index b66c95d..21b6b53 100644
--- a/app/assets/javascripts/discourse/app/models/user-stream.js
+++ b/app/assets/javascripts/discourse/app/models/user-stream.js
@@ -100,7 +100,7 @@ export default RestModel.extend({
     }
 
     this.set("loading", true);
-    return ajax(findUrl, { cache: "false" })
+    return ajax(findUrl)
       .then((result) => {
         if (result && result.no_results_help) {
           this.set("noContentHelp", result.no_results_help);
diff --git a/app/assets/javascripts/discourse/app/models/user.js b/app/assets/javascripts/discourse/app/models/user.js
index 667f915..4d8a9cf 100644
--- a/app/assets/javascripts/discourse/app/models/user.js
+++ b/app/assets/javascripts/discourse/app/models/user.js
@@ -524,27 +524,23 @@ const User = RestModel.extend({
 
   loadUserAction(id) {
     const stream = this.stream;
-    return ajax(`/user_actions/${id}.json`, { cache: "false" }).then(
-      (result) => {
-        if (result && result.user_action) {
-          const ua = result.user_action;
-
-          if (
-            (this.get("stream.filter") || ua.action_type) !== ua.action_type
-          ) {
-            return;
-          }
-          if (!this.get("stream.filter") && !this.inAllStream(ua)) {
-            return;
-          }
+    return ajax(`/user_actions/${id}.json`).then((result) => {
+      if (result && result.user_action) {
+        const ua = result.user_action;
 
-          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") || ua.action_type) !== ua.action_type) {
+          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]);
       }
-    );
+    });
   },
 
   inAllStream(ua) {
diff --git a/app/assets/javascripts/discourse/app/pre-initializers/theme-errors-handler.js b/app/assets/javascripts/discourse/app/pre-initializers/theme-errors-handler.js
index 05a9a0e..dd08a63 100644
--- a/app/assets/javascripts/discourse/app/pre-initializers/theme-errors-handler.js
+++ b/app/assets/javascripts/discourse/app/pre-initializers/theme-errors-handler.js
@@ -29,7 +29,6 @@ function reportToLogster(name, error) {
   Ember.$.ajax(getURL("/logs/report_js_error"), {
     data,
     type: "POST",
-    cache: false,
   });
 }
 
diff --git a/app/assets/javascripts/discourse/app/widgets/quick-access-bookmarks.js b/app/assets/javascripts/discourse/app/widgets/quick-access-bookmarks.js

[... diff too long, it was truncated ...]

GitHub sha: e06a2061

This commit appears in #13142 which was approved by eviltrout. It was merged by CvX.