# ajax-cache-parser

> A small function to get when an ajax request expires

Latest version **1.2.2** (published 2026-04-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install ajax-cache-parser
pnpm add ajax-cache-parser
yarn add ajax-cache-parser
bun add ajax-cache-parser
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities; has provenance; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2026-04-08 |
| First published | 2014-09-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2 |
| Author | Albert Wang |
| Maintainers | albertyw |

## Links

- npm: https://www.npmjs.com/package/ajax-cache-parser
- Repository: https://github.com/albertyw/ajax-cache-parser
- Homepage: https://github.com/albertyw/ajax-cache-parser#readme
- Issues: https://github.com/albertyw/ajax-cache-parser/issues
- npm.io page: https://npm.io/package/ajax-cache-parser

## Recent versions

- 1.2.2 (latest) — 2026-04-08
- 1.2.1 — 2025-04-18
- 1.2.0 — 2024-04-21
- 1.1.8 — 2022-12-16
- 1.1.7 — 2021-06-16
- 1.1.6 — 2021-03-31
- 1.1.5 — 2020-06-04
- 1.1.4 — 2019-12-27
- 1.1.3 — 2019-06-05
- 1.1.2 — 2016-10-08
- 1.1.1 — 2016-02-21
- 1.0.1 — 2015-11-01
- 1.1.0 — 2015-11-01
- 1.0.0 — 2014-09-07

## README

ajax-cache-parser
=================

[![NPM](https://nodei.co/npm/ajax-cache-parser.png?downloads=true&downloadRank=true)](https://nodei.co/npm/ajax-cache-parser/)

[![Build Status](https://drone.albertyw.com/api/badges/albertyw/ajax-cache-parser/status.svg)](https://drone.albertyw.com/albertyw/ajax-cache-parser)
[![Maintainability](https://qlty.sh/gh/albertyw/projects/ajax-cache-parser/maintainability.svg)](https://qlty.sh/gh/albertyw/projects/ajax-cache-parser)
[![Code Coverage](https://qlty.sh/gh/albertyw/projects/ajax-cache-parser/coverage.svg)](https://qlty.sh/gh/albertyw/projects/ajax-cache-parser)
[![install size](https://packagephobia.com/badge?p=ajax-cache-parser)](https://packagephobia.com/result?p=ajax-cache-parser)

A small function to get when an ajax request expires

Given an XMLHttpRequest object that has received response headers back from a server, `getCacheExpiry` will return
a javascript `Date` object that represents when the response will expire based on the `Expires` and `Cache-Control`
response headers.  If caching headers are not present or are unparseable, `undefined` will be returned.  If caching
headers indicate that the resource should not be cached, `null` will be returned.

Example
-------
```javascript
function callback(){
  var expiration = parser.getCacheExpiry(this);
  // do something with expiration
}
var oReq = new XMLHttpRequest();
oReq.onload = callback;
oReq.open("get", yourUrl, true);
oReq.send();
```

Information about caching headers comes from: https://www.mnot.net/cache_docs/

---
_Source: https://npm.io/package/ajax-cache-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
