Skip to content

Commit

Permalink
Merge pull request #1324 from hajkmap/feature/1323-hfetch-cacheBuster
Browse files Browse the repository at this point in the history
Reinstated cacheBuster to new-client
  • Loading branch information
jesade-vbg authored Apr 17, 2023
2 parents f8fef54 + 90ab0bf commit 4570f52
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions new-client/public/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<!DOCTYPE html>
<html lang="sv">
<head>
Expand All @@ -10,9 +11,11 @@
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-touch-fullscreen" content="yes" />
<meta name="description" content="Hajk - open source webGIS" />
<meta name="app-name" content="%REACT_APP_NAME%" />
<meta name="%REACT_APP_NAME%-build-date" content="%REACT_APP_BUILD_DATE%" />
<meta name="%REACT_APP_NAME%-git-hash" content="%REACT_APP_GIT_HASH%" />
<meta name="%REACT_APP_NAME%-version" content="%REACT_APP_VERSION%" />
<meta name="%REACT_APP_NAME%-use-cache-buster" content="%REACT_APP_USE_CACHE_BUSTER%" />

<link
rel="manifest"
Expand Down
17 changes: 13 additions & 4 deletions new-client/src/utils/FetchWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,20 @@ class FetchWrapper {
this.url = "";
this.options = {};

// Lets get the values from generated meta-tags
// Hash is used for cacheBuster function.
//this.hash = process?.env?.REACT_APP_GIT_HASH || null;
this.hash = null;
//this.useCacheBuster = process?.env?.REACT_APP_USE_CACHE_BUSTER === "true" || false;
this.useCacheBuster = false;
const appName =
document
.querySelector(`meta[name='app-name']`)
?.getAttribute("content") || "";
this.hash =
document
.querySelector(`meta[name='${appName}-git-hash']`)
?.getAttribute("content") || "";
this.useCacheBuster =
document
.querySelector(`meta[name='${appName}-use-cache-buster']`)
?.getAttribute("content") === "true";
}

matchesUrlPart(url, ruleWithWildCard) {
Expand Down

0 comments on commit 4570f52

Please sign in to comment.