7 examples of 'ajax nocache' in JavaScript

Every line of 'ajax nocache' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
342noCache() {
343 this.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
344 this.setHeader('Pragma', 'no-cache');
345 return this;
346}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

42public getCached (url: string, defaultValue?: any) {
43 return this.cache[url] || defaultValue
44}
65}, function notFoundLRU() {
66 Debug.debug(`DataURL: URL ${url} not found in LRU. Look for AJAX`);
67 return doByUrl(url, headers, options);
68});
57return doByUrl(url, headers, options).catch(function notFoundAjax() {
58 Debug.debug('DataURL: Failed in retrieving URL by AJAX. Fallback to cached version');
59 return data.data;
60});
100return doByUrl(url, headers, options).catch(function notFoundForceAjax() {
101 // If ajax fails (no internet), go for LRU
102 return doLRU(url, options).then(function foundLRUForceAjax(data) {
103 return data.data;
104 });
105});
95private addNoCacheToUrl(url: string) {
96 const separator = url.indexOf('?') === -1 ? '?' : '&';
97 const returnUrl = url + separator + 'noCache=' + new Date().getTime();
98
99 return returnUrl;
100}
56export function fromCache(url, cacheTime, updateCache, updateArguments) {
57 var cachedData = localStorage.getItem(url);
58 if (cachedData && cacheTime > Date.now()) {
59 return Promise.resolve(html`<div class="root" innerHTML="${cachedData}"></div>`);
60 }
61 return new Promise((accept, reject) => {
62 updateCache(url, updateArguments).then(parsedHtml => {
63 localStorage.setItem(url, parsedHtml);
64 localStorage.setItem("timestamp_" + url, Date.now());
65 setTimeout(() => accept(html`<div class="root" innerHTML="${parsedHtml}"></div>`), 1);
66 }).catch(e => reject(e));
67 });
68}

Related snippets