From 8ef99b336ce9576dbfe07e27462219e98e9c2ea8 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 9 Feb 2024 14:56:17 +0800 Subject: [PATCH] Remove 'no cache' directive for POST requests The response for POST request is only cachable under a specific condition and qbt doesn't use it. https://developer.mozilla.org/en-US/docs/Glossary/Cacheable --- src/webui/www/private/confirmfeeddeletion.html | 1 - src/webui/www/private/confirmruledeletion.html | 1 - src/webui/www/private/newfeed.html | 1 - src/webui/www/private/newfolder.html | 1 - src/webui/www/private/newrule.html | 1 - src/webui/www/private/rename_feed.html | 1 - src/webui/www/private/rename_rule.html | 1 - src/webui/www/private/scripts/download.js | 2 +- src/webui/www/private/scripts/prop-files.js | 2 +- src/webui/www/private/scripts/prop-general.js | 4 ++-- src/webui/www/private/scripts/prop-peers.js | 3 +-- src/webui/www/private/scripts/prop-trackers.js | 2 +- src/webui/www/private/scripts/prop-webseeds.js | 2 +- src/webui/www/private/scripts/speedslider.js | 2 -- src/webui/www/private/views/installsearchplugin.html | 1 - src/webui/www/private/views/log.html | 2 +- src/webui/www/private/views/rss.html | 5 +---- src/webui/www/private/views/rssDownloader.html | 10 ++++------ src/webui/www/private/views/search.html | 6 ++---- src/webui/www/private/views/searchplugins.html | 3 --- 20 files changed, 15 insertions(+), 36 deletions(-) diff --git a/src/webui/www/private/confirmfeeddeletion.html b/src/webui/www/private/confirmfeeddeletion.html index 053cacc3d..a77ecba0a 100644 --- a/src/webui/www/private/confirmfeeddeletion.html +++ b/src/webui/www/private/confirmfeeddeletion.html @@ -23,7 +23,6 @@ paths.forEach((path) => { new Request({ url: 'api/v2/rss/removeItem', - noCache: true, method: 'post', data: { path: decodeURIComponent(path) diff --git a/src/webui/www/private/confirmruledeletion.html b/src/webui/www/private/confirmruledeletion.html index 6418ff122..7b9614456 100644 --- a/src/webui/www/private/confirmruledeletion.html +++ b/src/webui/www/private/confirmruledeletion.html @@ -24,7 +24,6 @@ rules.forEach((rule) => { new Request({ url: 'api/v2/rss/removeRule', - noCache: true, method: 'post', data: { ruleName: decodeURIComponent(rule) diff --git a/src/webui/www/private/newfeed.html b/src/webui/www/private/newfeed.html index 496e68940..37ba92a90 100644 --- a/src/webui/www/private/newfeed.html +++ b/src/webui/www/private/newfeed.html @@ -44,7 +44,6 @@ new Request({ url: 'api/v2/rss/addFeed', - noCache: true, method: 'post', data: { url: feedURL, diff --git a/src/webui/www/private/newfolder.html b/src/webui/www/private/newfolder.html index 5429d2575..aebe054b3 100644 --- a/src/webui/www/private/newfolder.html +++ b/src/webui/www/private/newfolder.html @@ -44,7 +44,6 @@ new Request({ url: 'api/v2/rss/addFolder', - noCache: true, method: 'post', data: { path: path ? (path + '\\' + folderName) : folderName diff --git a/src/webui/www/private/newrule.html b/src/webui/www/private/newrule.html index 99cb8ba78..a732673fe 100644 --- a/src/webui/www/private/newrule.html +++ b/src/webui/www/private/newrule.html @@ -41,7 +41,6 @@ $('submitButton').disabled = true; new Request({ url: 'api/v2/rss/setRule', - noCache: true, method: 'post', data: { ruleName: name, diff --git a/src/webui/www/private/rename_feed.html b/src/webui/www/private/rename_feed.html index 4698c6e47..0b69065f5 100644 --- a/src/webui/www/private/rename_feed.html +++ b/src/webui/www/private/rename_feed.html @@ -53,7 +53,6 @@ new Request({ url: 'api/v2/rss/moveItem', - noCache: true, method: 'post', data: { itemPath: oldPath, diff --git a/src/webui/www/private/rename_rule.html b/src/webui/www/private/rename_rule.html index cbc252c3c..6ce03e4a0 100644 --- a/src/webui/www/private/rename_rule.html +++ b/src/webui/www/private/rename_rule.html @@ -52,7 +52,6 @@ $('renameButton').disabled = true; new Request({ url: 'api/v2/rss/renameRule', - noCache: true, method: 'post', data: { ruleName: oldName, diff --git a/src/webui/www/private/scripts/download.js b/src/webui/www/private/scripts/download.js index 9918e6c18..cbfc52c7d 100644 --- a/src/webui/www/private/scripts/download.js +++ b/src/webui/www/private/scripts/download.js @@ -41,8 +41,8 @@ window.qBittorrent.Download = (function() { const getCategories = function() { new Request.JSON({ url: 'api/v2/torrents/categories', - noCache: true, method: 'get', + noCache: true, onSuccess: function(data) { if (data) { categories = data; diff --git a/src/webui/www/private/scripts/prop-files.js b/src/webui/www/private/scripts/prop-files.js index 19ae1c6bc..f16809d2e 100644 --- a/src/webui/www/private/scripts/prop-files.js +++ b/src/webui/www/private/scripts/prop-files.js @@ -358,8 +358,8 @@ window.qBittorrent.PropFiles = (function() { const url = new URI('api/v2/torrents/files?hash=' + current_hash); new Request.JSON({ url: url, - noCache: true, method: 'get', + noCache: true, onComplete: function() { clearTimeout(loadTorrentFilesDataTimer); loadTorrentFilesDataTimer = loadTorrentFilesData.delay(5000); diff --git a/src/webui/www/private/scripts/prop-general.js b/src/webui/www/private/scripts/prop-general.js index 6b9dbacda..6e18831c4 100644 --- a/src/webui/www/private/scripts/prop-general.js +++ b/src/webui/www/private/scripts/prop-general.js @@ -90,8 +90,8 @@ window.qBittorrent.PropGeneral = (function() { const url = new URI('api/v2/torrents/properties?hash=' + current_id); new Request.JSON({ url: url, - noCache: true, method: 'get', + noCache: true, onFailure: function() { $('error_div').set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]'); clearTimeout(loadTorrentDataTimer); @@ -223,8 +223,8 @@ window.qBittorrent.PropGeneral = (function() { const piecesUrl = new URI('api/v2/torrents/pieceStates?hash=' + current_id); new Request.JSON({ url: piecesUrl, - noCache: true, method: 'get', + noCache: true, onFailure: function() { $('error_div').set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]'); clearTimeout(loadTorrentDataTimer); diff --git a/src/webui/www/private/scripts/prop-peers.js b/src/webui/www/private/scripts/prop-peers.js index 660e6bb22..5c893d894 100644 --- a/src/webui/www/private/scripts/prop-peers.js +++ b/src/webui/www/private/scripts/prop-peers.js @@ -64,8 +64,8 @@ window.qBittorrent.PropPeers = (function() { url.setData('hash', current_hash); new Request.JSON({ url: url, - noCache: true, method: 'get', + noCache: true, onComplete: function() { clearTimeout(loadTorrentPeersTimer); loadTorrentPeersTimer = loadTorrentPeersData.delay(window.qBittorrent.Client.getSyncMainDataInterval()); @@ -144,7 +144,6 @@ window.qBittorrent.PropPeers = (function() { if (confirm('QBT_TR(Are you sure you want to permanently ban the selected peers?)QBT_TR[CONTEXT=PeerListWidget]')) { new Request({ url: 'api/v2/transfer/banPeers', - noCache: true, method: 'post', data: { hash: torrentsTable.getCurrentTorrentID(), diff --git a/src/webui/www/private/scripts/prop-trackers.js b/src/webui/www/private/scripts/prop-trackers.js index e1c4ddaa0..015759a99 100644 --- a/src/webui/www/private/scripts/prop-trackers.js +++ b/src/webui/www/private/scripts/prop-trackers.js @@ -64,8 +64,8 @@ window.qBittorrent.PropTrackers = (function() { const url = new URI('api/v2/torrents/trackers?hash=' + current_hash); new Request.JSON({ url: url, - noCache: true, method: 'get', + noCache: true, onComplete: function() { clearTimeout(loadTrackersDataTimer); loadTrackersDataTimer = loadTrackersData.delay(10000); diff --git a/src/webui/www/private/scripts/prop-webseeds.js b/src/webui/www/private/scripts/prop-webseeds.js index ce42d0343..cadd8ab9e 100644 --- a/src/webui/www/private/scripts/prop-webseeds.js +++ b/src/webui/www/private/scripts/prop-webseeds.js @@ -113,8 +113,8 @@ window.qBittorrent.PropWebseeds = (function() { const url = new URI('api/v2/torrents/webseeds?hash=' + current_hash); new Request.JSON({ url: url, - noCache: true, method: 'get', + noCache: true, onFailure: function() { $('error_div').set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]'); clearTimeout(loadWebSeedsDataTimer); diff --git a/src/webui/www/private/scripts/speedslider.js b/src/webui/www/private/scripts/speedslider.js index be27c8f53..fe14cfc02 100644 --- a/src/webui/www/private/scripts/speedslider.js +++ b/src/webui/www/private/scripts/speedslider.js @@ -85,7 +85,6 @@ MochaUI.extend({ else { new Request.JSON({ url: 'api/v2/torrents/uploadLimit', - noCache: true, method: 'post', data: { hashes: hashes.join('|') @@ -189,7 +188,6 @@ MochaUI.extend({ else { new Request.JSON({ url: 'api/v2/torrents/downloadLimit', - noCache: true, method: 'post', data: { hashes: hashes.join('|') diff --git a/src/webui/www/private/views/installsearchplugin.html b/src/webui/www/private/views/installsearchplugin.html index 5e8d1a0d6..4d9ee70c0 100644 --- a/src/webui/www/private/views/installsearchplugin.html +++ b/src/webui/www/private/views/installsearchplugin.html @@ -65,7 +65,6 @@ if (path) new Request({ url: 'api/v2/search/installPlugin', - noCache: true, method: 'post', data: { sources: path, diff --git a/src/webui/www/private/views/log.html b/src/webui/www/private/views/log.html index 9cfa6a98a..3f12aeb4e 100644 --- a/src/webui/www/private/views/log.html +++ b/src/webui/www/private/views/log.html @@ -361,8 +361,8 @@ new Request.JSON({ url: url, - noCache: true, method: 'get', + noCache: true, onFailure: function(response) { const errorDiv = $('error_div'); if (errorDiv) diff --git a/src/webui/www/private/views/rss.html b/src/webui/www/private/views/rss.html index 520ccf582..2db79f86f 100644 --- a/src/webui/www/private/views/rss.html +++ b/src/webui/www/private/views/rss.html @@ -446,8 +446,8 @@ const updateRssFeedList = () => { new Request.JSON({ url: 'api/v2/rss/items', - noCache: true, method: 'get', + noCache: true, data: { withData: true }, @@ -668,7 +668,6 @@ new Request({ url: 'api/v2/rss/refreshItem', - noCache: true, method: 'post', data: { itemPath: pathByFeedId.get(feedUid) @@ -746,7 +745,6 @@ // send request new Request({ url: 'api/v2/rss/markAsRead', - noCache: true, method: 'post', data: { itemPath: path @@ -787,7 +785,6 @@ new Request({ url: 'api/v2/rss/markAsRead', - noCache: true, method: 'post', data: { itemPath: path, diff --git a/src/webui/www/private/views/rssDownloader.html b/src/webui/www/private/views/rssDownloader.html index f75e53280..02ab5085e 100644 --- a/src/webui/www/private/views/rssDownloader.html +++ b/src/webui/www/private/views/rssDownloader.html @@ -436,8 +436,8 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also // get all categories and add to combobox new Request.JSON({ url: 'api/v2/torrents/categories', - noCache: true, method: 'get', + noCache: true, onSuccess: (response) => { let combobox = $('assignCategoryCombobox'); for (let cat in response) { @@ -450,8 +450,8 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also // get all rss feed new Request.JSON({ url: 'api/v2/rss/items', - noCache: true, method: 'get', + noCache: true, data: { withData: false }, @@ -478,8 +478,8 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also // get all rules new Request.JSON({ url: 'api/v2/rss/rules', - noCache: true, method: 'get', + noCache: true, onSuccess: (response) => { rssDownloaderRulesTable.clear(); let rowCount = 0; @@ -500,7 +500,6 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also rulesList[rule][setting] = newState; new Request({ url: 'api/v2/rss/setRule', - noCache: true, method: 'post', data: { ruleName: rule, @@ -627,7 +626,6 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also new Request({ url: 'api/v2/rss/setRule', - noCache: true, method: 'post', data: { ruleName: rule, @@ -642,8 +640,8 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also const updateMatchingArticles = (ruleName) => { new Request.JSON({ url: 'api/v2/rss/matchingArticles', - noCache: true, method: 'get', + noCache: true, data: { ruleName: ruleName }, diff --git a/src/webui/www/private/views/search.html b/src/webui/www/private/views/search.html index f11337586..2c24341e8 100644 --- a/src/webui/www/private/views/search.html +++ b/src/webui/www/private/views/search.html @@ -303,7 +303,6 @@ const url = new URI('api/v2/search/start'); new Request.JSON({ url: url, - noCache: true, method: 'post', data: { pattern: pattern, @@ -323,7 +322,6 @@ const url = new URI('api/v2/search/stop'); new Request({ url: url, - noCache: true, method: 'post', data: { id: activeSearchId @@ -515,8 +513,8 @@ const getPlugins = function() { new Request.JSON({ url: new URI('api/v2/search/plugins'), - noCache: true, method: 'get', + noCache: true, onSuccess: function(response) { if (response !== prevSearchPluginsResponse) { prevSearchPluginsResponse = response; @@ -641,8 +639,8 @@ const url = new URI('api/v2/search/results'); new Request.JSON({ url: url, - noCache: true, method: 'get', + noCache: true, data: { id: activeSearchId, limit: maxResults, diff --git a/src/webui/www/private/views/searchplugins.html b/src/webui/www/private/views/searchplugins.html index 9bb73c2ca..4e18d4923 100644 --- a/src/webui/www/private/views/searchplugins.html +++ b/src/webui/www/private/views/searchplugins.html @@ -138,7 +138,6 @@ const url = new URI('api/v2/search/uninstallPlugin'); new Request({ url: url, - noCache: true, method: 'post', data: { names: plugins, @@ -155,7 +154,6 @@ const url = new URI('api/v2/search/enablePlugin'); new Request({ url: url, - noCache: true, method: 'post', data: { names: plugins.join('|'), @@ -168,7 +166,6 @@ const url = new URI('api/v2/search/updatePlugins'); new Request({ url: url, - noCache: true, method: 'post' }).send(); };