diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index c3e6cea10c..39d7db81a4 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -139,6 +139,7 @@ def getSettings(): "flipH": s.getBoolean(["webcam", "flipH"]), "flipV": s.getBoolean(["webcam", "flipV"]), "rotate90": s.getBoolean(["webcam", "rotate90"]), + "cacheBuster": s.getBoolean(["webcam", "cacheBuster"]), }, "feature": { "temperatureGraph": s.getBoolean(["feature", "temperatureGraph"]), @@ -593,6 +594,8 @@ def _saveSettings(data): s.setBoolean(["webcam", "flipV"], data["webcam"]["flipV"]) if "rotate90" in data["webcam"]: s.setBoolean(["webcam", "rotate90"], data["webcam"]["rotate90"]) + if "cacheBuster" in data["webcam"]: + s.setBoolean(["webcam", "cacheBuster"], data["webcam"]["cacheBuster"]) if "feature" in data: if "temperatureGraph" in data["feature"]: diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index b6b9533a6e..2a7c9fe39b 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -265,6 +265,7 @@ def settings(init=False, basedir=None, configfile=None, overlays=None): "fps": 25, }, "cleanTmpAfterDays": 7, + "cacheBuster": False, }, "gcodeAnalysis": { "maxExtruders": 10, diff --git a/src/octoprint/static/js/app/viewmodels/control.js b/src/octoprint/static/js/app/viewmodels/control.js index 850fa08488..f440241ef8 100644 --- a/src/octoprint/static/js/app/viewmodels/control.js +++ b/src/octoprint/static/js/app/viewmodels/control.js @@ -688,12 +688,14 @@ $(function () { var newSrc = self.settings.webcam_streamUrl(); if (currentSrc != newSrc) { - if (newSrc.lastIndexOf("?") > -1) { - newSrc += "&"; - } else { - newSrc += "?"; + if (self.settings.webcam_cacheBuster()) { + if (newSrc.lastIndexOf("?") > -1) { + newSrc += "&"; + } else { + newSrc += "?"; + } + newSrc += new Date().getTime(); } - newSrc += new Date().getTime(); self.webcamLoaded(false); self.webcamError(false); diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index a3b919556f..15e436f321 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -165,6 +165,7 @@ $(function () { self.webcam_flipH = ko.observable(undefined); self.webcam_flipV = ko.observable(undefined); self.webcam_rotate90 = ko.observable(undefined); + self.webcam_cacheBuster = ko.observable(undefined); self.feature_temperatureGraph = ko.observable(undefined); self.feature_sdSupport = ko.observable(undefined); diff --git a/src/octoprint/templates/dialogs/settings/webcam.jinja2 b/src/octoprint/templates/dialogs/settings/webcam.jinja2 index 63f9a707a6..13a15a3f5e 100644 --- a/src/octoprint/templates/dialogs/settings/webcam.jinja2 +++ b/src/octoprint/templates/dialogs/settings/webcam.jinja2 @@ -14,6 +14,7 @@