Nonlinear Programming Methods

    ajax-cache-parser

    1.1.7 • Public • Published

    ajax-cache-parser

    NPM

    Build Status Code Climate Test Coverage dependencies Status devDependencies Status

    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

    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/

    Keywords

    none

    Install

    npm i ajax-cache-parser

    DownloadsWeekly Downloads

    5

    Version

    1.1.7

    License

    MIT

    Unpacked Size

    14 kB

    Total Files

    7

    Last publish

    Collaborators

    • albertyw