UNPKG

843 BMarkdownView Raw
1ajax-cache-parser
2=================
3
4A small function to get when an ajax request expires
5
6Given an XMLHttpRequest object that has received response headers back from a server, `getCacheExpiry` will return
7a javascript `Date` object that represents when the response will expire based on the `Expires` and `Cache-Control`
8response headers. If caching headers are not present or are unparseable, `undefined` will be returned. If caching
9headers indicate that the resource should not be cached, `null` will be returned.
10
11Example
12-------
13```javascript
14function callback(){
15 var expiration = parser.getCacheExpiry(this);
16 // do something with expiration
17}
18var oReq = new XMLHttpRequest();
19oReq.onload = callback;
20oReq.open("get", yourUrl, true);
21oReq.send();
22```
23
24Information about caching headers comes from: https://www.mnot.net/cache_docs/