{"id":15311062,"url":"https://github.com/talentlessguy/es-fresh","last_synced_at":"2025-04-15T01:09:04.067Z","repository":{"id":52291598,"uuid":"279183372","full_name":"talentlessguy/es-fresh","owner":"talentlessguy","description":"fresh rewrite in TypeScript with ESM and CommonJS targets","archived":false,"fork":false,"pushed_at":"2024-09-11T17:04:49.000Z","size":67,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T01:08:58.303Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/talentlessguy.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}},"created_at":"2020-07-13T01:50:18.000Z","updated_at":"2024-09-11T17:04:52.000Z","dependencies_parsed_at":"2023-02-04T21:15:36.842Z","dependency_job_id":null,"html_url":"https://github.com/talentlessguy/es-fresh","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talentlessguy%2Fes-fresh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talentlessguy%2Fes-fresh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talentlessguy%2Fes-fresh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talentlessguy%2Fes-fresh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/talentlessguy","download_url":"https://codeload.github.com/talentlessguy/es-fresh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248986313,"owners_count":21194025,"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":[],"created_at":"2024-10-01T08:31:02.485Z","updated_at":"2025-04-15T01:09:04.051Z","avatar_url":"https://github.com/talentlessguy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# es-fresh\n\n![Top language][top-lang-image]\n![Vulnerabilities][snyk-image]\n[![Version][npm-v-image]][npm-url]\n[![Node Version][node-version-image]][node-version-url]\n![Last commit][last-commit-image]\n\n\u003e This is a copy of [@foxify/fresh](https://github.com/foxifyjs/fresh) package but with ESM and CommonJS targets.\n\nHTTP response freshness testing.\n\n## Install\n\n```sh\npnpm i es-fresh\n```\n\n## API\n\n```ts\nimport fresh from 'es-fresh'\n```\n\n### `fresh(reqHeaders, resHeaders)`\n\nCheck freshness of the response using request and response headers.\n\nWhen the response is still \"fresh\" in the client's cache `true` is\nreturned, otherwise `false` is returned to indicate that the client\ncache is now stale and the full response should be sent.\n\nWhen a client sends the `Cache-Control: no-cache` request header to\nindicate an end-to-end reload request, this module will return `false`\nto make handling these requests transparent.\n\n## Example\n\n```ts\nimport fresh from 'es-fresh'\nimport { createServer } from 'http'\n\nfunction isFresh(req, res) {\n  return fresh(req.headers, {\n    etag: res.getHeader('ETag'),\n    'last-modified': res.getHeader('Last-Modified'),\n  })\n}\n\ncreateServer((req, res) =\u003e {\n  // perform server logic\n  // ... including adding ETag / Last-Modified response headers\n\n  if (isFresh(req, res)) {\n    // client has a fresh copy of resource\n    res.statusCode = 304\n    res.end()\n    return\n  }\n\n  // send the resource\n  res.statusCode = 200\n  res.end('hello, world!')\n}).listen(3000)\n```\n\n## License\n\nMIT © [v1rtl](https://v1rtl.site)\n\n[node-version-image]: https://img.shields.io/node/v/es-fresh.svg?style=flat-square\n[node-version-url]: https://nodejs.org\n[top-lang-image]: https://img.shields.io/github/languages/top/talentlessguy/es-fresh.svg?style=flat-square\n[snyk-image]: https://img.shields.io/snyk/vulnerabilities/npm/es-fresh.svg?style=flat-square\n[npm-v-image]: https://img.shields.io/npm/v/es-fresh.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/es-fresh\n[last-commit-image]: https://img.shields.io/github/last-commit/talentlessguy/es-fresh.svg?style=flat-square\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalentlessguy%2Fes-fresh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftalentlessguy%2Fes-fresh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalentlessguy%2Fes-fresh/lists"}