github lukeed/worktop v0.5.2

latest releases: v0.8.0-next.18, v0.8.0-next.16, v0.8.0-next.17...
3 years ago

Features

  • (cache): Attempt a GET match in Cache.lookup method with incoming HEAD request (#44): 1a27c9c
    When the incoming request is a HEAD method, try to look for its GET counterpart in the Cache.

    API.add('GET', '/articles', async (req, res) => {
      // heavy DB query processing, etc
      const items = await expensive('task');
      res.send(200, items);
    });
    
    // BEFORE
    // ---
    // request -> "GET  /articles" -> Cache MISS -> execute -> Cache PUT -> Response
    // request -> "GET  /articles" -> Cache HIT  -> Response
    // request -> "HEAD /articles" -> Cache HIT  -> execute -> Cache PUT -> Response
    
    // AFTER
    // ---
    // request -> "GET  /articles" -> Cache MISS -> execute -> Cache PUT -> Response
    // request -> "GET  /articles" -> Cache HIT  -> Response
    // request -> "HEAD /articles" -> Cache HIT  -> Response

Patches

  • (router): Prevent early exit via compose in prepare hook (#43): a1ab931
    When using compose() to create a $.prepare handler, a Response was always returned from $.prepare, preventing any/all route handlers from running. This has been fixed.

  • (cache): Do not try to Cache.put for HEAD requests (#44): e69859c
    This technically was throwing at runtime error, which didn't affect the Response – thanks to event.waitUntil.

Don't miss a new worktop release

NewReleases is sending notifications on new releases.