Skip to content

Instantly share code, notes, and snippets.

@luislobo14rap
Created August 7, 2020 22:10
Show Gist options
  • Save luislobo14rap/cae476de147d035da8ea794e74b3cd5b to your computer and use it in GitHub Desktop.
Save luislobo14rap/cae476de147d035da8ea794e74b3cd5b to your computer and use it in GitHub Desktop.
cache-expires-after.js
// cache-expires-after.js v1
function cacheExpiresAfter(delay = 1, prefix = '', suffix = '') { // seconds
let now = new Date().getTime().toString();
now = now.substring(now.length - 11, 10); // remove decades and milliseconds
now = parseInt(now / delay).toString();
return prefix + now + suffix;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment