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