Skip to content

Instantly share code, notes, and snippets.

@hexchain
Created March 19, 2025 16:51
Show Gist options
  • Save hexchain/1b266612ac7bc217dae48526e54d225a to your computer and use it in GitHub Desktop.
Save hexchain/1b266612ac7bc217dae48526e54d225a to your computer and use it in GitHub Desktop.
import CachePolicy from 'http-cache-semantics';
const request: CachePolicy.Request = {
url: 'http://example.com/a.txt',
method: 'GET',
headers: {
'accept-encoding': 'gzip, br, zstd'
}
};
const response: CachePolicy.Response = {
status: 200,
headers: {
'cache-control': 'max-age=300'
}
};
const policy = new CachePolicy(request, response, { shared: true });
console.log(policy.toObject());
{
"name": "test",
"version": "1.0.0",
"scripts": {
"check": "tsc --noEmit"
},
"dependencies": {
"http-cache-semantics": "github:kornelski/http-cache-semantics"
},
"devDependencies": {
"typescript": "^5.8.2"
}
}
{
"compilerOptions": {
"allowJs": true,
"noImplicitAny": true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment