summaryrefslogtreecommitdiff
path: root/src/store/api.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/store/api.js')
-rw-r--r--src/store/api.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/store/api.js b/src/store/api.js
index 9fd900d2..0bd84e62 100644
--- a/src/store/api.js
+++ b/src/store/api.js
@@ -1,4 +1,6 @@
import Axios from 'axios';
+import { setupCache, buildWebStorage } from 'axios-cache-interceptor';
+
//Do not change store import.
//Exact match alias set to support
//dotenv customizations.
@@ -7,10 +9,21 @@ import store from '../store';
Axios.defaults.headers.common['Accept'] = 'application/json';
Axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
-const api = Axios.create({
+const axiosInstance = Axios.create({
withCredentials: true,
});
+const api = setupCache(axiosInstance, {
+ debug: console.log,
+ methods: ['get'],
+ interpretHeader: false,
+ etag: true,
+ modifiedSince: false,
+ staleIfError: false,
+ ttl: 0,
+ storage: buildWebStorage(localStorage, 'webui-vue-cache:'),
+});
+
api.interceptors.response.use(undefined, (error) => {
let response = error.response;