{"id":17125023,"url":"https://github.com/tusbar/cache-control","last_synced_at":"2025-04-05T17:03:41.592Z","repository":{"id":39878203,"uuid":"116163608","full_name":"tusbar/cache-control","owner":"tusbar","description":"Format and parse HTTP Cache-Control header","archived":false,"fork":false,"pushed_at":"2025-03-24T21:12:15.000Z","size":2764,"stargazers_count":40,"open_issues_count":10,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T16:03:24.453Z","etag":null,"topics":["cache-control","http","javascript","nodejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tusbar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-03T17:25:17.000Z","updated_at":"2025-03-11T08:22:19.000Z","dependencies_parsed_at":"2022-09-05T08:31:22.914Z","dependency_job_id":"458bed34-7ae1-4df5-932b-5585d76c45b2","html_url":"https://github.com/tusbar/cache-control","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusbar%2Fcache-control","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusbar%2Fcache-control/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusbar%2Fcache-control/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusbar%2Fcache-control/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tusbar","download_url":"https://codeload.github.com/tusbar/cache-control/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369953,"owners_count":20927928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache-control","http","javascript","nodejs"],"created_at":"2024-10-14T18:43:55.050Z","updated_at":"2025-04-05T17:03:41.546Z","avatar_url":"https://github.com/tusbar.png","language":"TypeScript","readme":"# cache-control\n\n\u003e Format and parse HTTP Cache-Control header\n\n[![npm version](https://badgen.net/npm/v/@tusbar/cache-control)](https://www.npmjs.com/package/@tusbar/cache-control)\n[![codecov](https://codecov.io/gh/tusbar/cache-control/graph/badge.svg?token=O8MvGFz46p)](https://codecov.io/gh/tusbar/cache-control)\n[![XO code style](https://badgen.net/badge/code%20style/XO/cyan)](https://github.com/xojs/xo)\n\n## CI\n\n[![Tests](https://github.com/tusbar/cache-control/actions/workflows/tests.yml/badge.svg)](https://github.com/tusbar/cache-control/actions/workflows/tests.yml)\n[![Release](https://github.com/tusbar/cache-control/actions/workflows/release.yml/badge.svg)](https://github.com/tusbar/cache-control/actions/workflows/release.yml)\n\n## Getting started\n\n```bash\n$ npm install @tusbar/cache-control\n```\n\n## API\n\nThis library exposes a `CacheControl` class and two shortcut methods: `parse()` and `format()`.\n\n### `parse(header)`\n\n```js\nconst {parse} = require('@tusbar/cache-control')\n```\n\n`parse()` takes a `Cache-Control` HTTP header value and returns a `CacheControl` instance.\n\nFor example, `parse('max-age=31536000, public')` will return\n\n```js\nCacheControl {\n  maxAge: 31536000,\n  sharedMaxAge: null,\n  maxStale: false,\n  maxStaleDuration: null,\n  minFresh: null,\n  immutable: false,\n  mustRevalidate: false,\n  noCache: false,\n  noStore: false,\n  noTransform: false,\n  onlyIfCached: false,\n  private: false,\n  proxyRevalidate: false,\n  public: true,\n  staleIfError: null,\n  staleWhileRevalidate: null }\n```\n\n### `format(cacheControl)`\n\n```js\nconst {format} = require('@tusbar/cache-control')\n```\n\n`format()` takes a `CacheControl` instance (or similar object) and returns a `Cache-Control` HTTP header value.\n\nFor example, `format({maxAge: 31536000, public: true})` will return\n\n```js\nmax-age=31536000, public\n```\n\n## Example usage\n\n```js\nres.setHeader('Cache-Control', format({\n  public: true,\n  immutable: true\n}))\n```\n\n## FAQ\n\n**Why another cache-control library?**\n\nNone of the existing libraries focus on just parsing the `Cache-Control` headers. There are some that expose Express (or connect-like) middlewares, and some unmaintained other ones that do rudimentary parsing of the header. The idea of this module is to parse the header according to the RFC with no further analysis or integration.\n\n\n## See also\n\n- [`cachecontrol`](https://github.com/pquerna/cachecontrol): Golang HTTP Cache-Control Parser and Interpretation\n\n\n## License\n\nMIT\n\n\n## Miscellaneous\n\n```\n    ╚⊙ ⊙╝\n  ╚═(███)═╝\n ╚═(███)═╝\n╚═(███)═╝\n ╚═(███)═╝\n  ╚═(███)═╝\n   ╚═(███)═╝\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftusbar%2Fcache-control","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftusbar%2Fcache-control","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftusbar%2Fcache-control/lists"}