Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to pass cache bust param #3525

Merged
merged 16 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions db/patch-add-cache-bust.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
BEGIN TRANSACTION;

ALTER TABLE monitor
ADD cache_bust BOOLEAN default 0 not null;

COMMIT;
1 change: 1 addition & 0 deletions server/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class Database {
"patch-added-kafka-producer.sql": true,
"patch-add-certificate-expiry-status-page.sql": true,
"patch-monitor-oauth-cc.sql": true,
"patch-add-cache-bust.sql": true,
CommanderStorm marked this conversation as resolved.
Show resolved Hide resolved
};

/**
Expand Down
21 changes: 21 additions & 0 deletions server/model/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class Monitor extends BeanModel {
kafkaProducerAllowAutoTopicCreation: this.kafkaProducerAllowAutoTopicCreation === "1" && true || false,
kafkaProducerMessage: this.kafkaProducerMessage,
screenshot,
cacheBust: this.getCacheBust(),
dansullivan86 marked this conversation as resolved.
Show resolved Hide resolved
};

if (includeSensitiveData) {
Expand Down Expand Up @@ -271,6 +272,14 @@ class Monitor extends BeanModel {
return Boolean(this.grpcEnableTls);
}

/**
* Parse to boolean
* @returns {boolean}
CommanderStorm marked this conversation as resolved.
Show resolved Hide resolved
*/
getCacheBust() {
return Boolean(this.cacheBust);
}

dansullivan86 marked this conversation as resolved.
Show resolved Hide resolved
/**
* Get accepted status codes
* @returns {Object}
Expand Down Expand Up @@ -447,6 +456,18 @@ class Monitor extends BeanModel {
options.data = bodyValue;
}

if (this.cacheBust) {
let cacheBust = "";
const characters = "abcdefghijklmnopqrstuvwxyz0123456789";
const charactersLength = characters.length;
for (let i = 0; i < 6; i++) {
cacheBust += characters.charAt(Math.floor(Math.random() * charactersLength));
}
dansullivan86 marked this conversation as resolved.
Show resolved Hide resolved
options.params = {
dansullivan86 marked this conversation as resolved.
Show resolved Hide resolved
uptime_kuma_cachebuster: cacheBust,
};
}

if (this.proxy_id) {
const proxy = await R.load("proxy", this.proxy_id);

Expand Down
2 changes: 2 additions & 0 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ let needSetup = false;
bean.kafkaProducerAllowAutoTopicCreation = monitor.kafkaProducerAllowAutoTopicCreation;
bean.kafkaProducerSaslOptions = JSON.stringify(monitor.kafkaProducerSaslOptions);
bean.kafkaProducerMessage = monitor.kafkaProducerMessage;
bean.cacheBust = monitor.cacheBust;

bean.validate();

Expand Down Expand Up @@ -1413,6 +1414,7 @@ let needSetup = false;
dns_resolve_server: monitorListData[i].dns_resolve_server,
notificationIDList: monitorListData[i].notificationIDList,
proxy_id: monitorListData[i].proxy_id || null,
cacheBust: monitorListData[i].cacheBust,
};

if (monitorListData[i].pushToken) {
Expand Down
3 changes: 2 additions & 1 deletion src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -799,5 +799,6 @@
"nostrRecipients": "Recipients Public Keys (npub)",
"nostrRecipientsHelp": "npub format, one per line",
"showCertificateExpiry": "Show Certificate Expiry",
"noOrBadCertificate": "No/Bad Certificate"
"noOrBadCertificate": "No/Bad Certificate",
"cacheBusterParam": "Add Cache Buster Param"
dansullivan86 marked this conversation as resolved.
Show resolved Hide resolved
}
8 changes: 8 additions & 0 deletions src/pages/EditMonitor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,13 @@
</label>
</div>

<div v-if="monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' " class="my-3 form-check">
<input id="cache-bust" v-model="monitor.cacheBust" class="form-check-input" type="checkbox" value="">
<label class="form-check-label" for="cache-bust">
{{ $t("cacheBusterParam") }}
</label>
</div>

<div class="my-3 form-check">
<input id="upside-down" v-model="monitor.upsideDown" class="form-check-input" type="checkbox">
<label class="form-check-label" for="upside-down">
Expand Down Expand Up @@ -863,6 +870,7 @@ const monitorDefaults = {
kafkaProducerSaslOptions: {
mechanism: "None",
},
cacheBust: false,
};

export default {
Expand Down