Socket
Socket
Sign inDemoInstall

koa-etag

Package Overview
Dependencies
Maintainers
9
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-etag

ETag support for koa


Version published
Weekly downloads
192K
decreased by-1.95%
Maintainers
9
Weekly downloads
 
Created

What is koa-etag?

The koa-etag package is a middleware for Koa that automatically handles ETag (Entity Tag) headers for HTTP responses. ETags are used for web cache validation and conditional requests, helping to reduce bandwidth and improve web application performance.

What are koa-etag's main functionalities?

Automatic ETag Generation

This feature automatically generates ETag headers for HTTP responses. The middleware calculates the ETag based on the response body and sets the appropriate header.

const Koa = require('koa');
const etag = require('koa-etag');
const app = new Koa();

app.use(etag());

app.use(async (ctx) => {
  ctx.body = 'Hello World';
});

app.listen(3000);

Conditional GET Requests

This feature works in conjunction with the koa-conditional-get middleware to handle conditional GET requests. If the ETag matches the client's cached version, a 304 Not Modified response is sent, saving bandwidth.

const Koa = require('koa');
const etag = require('koa-etag');
const conditional = require('koa-conditional-get');
const app = new Koa();

app.use(conditional());
app.use(etag());

app.use(async (ctx) => {
  ctx.body = 'Hello World';
});

app.listen(3000);

Other packages similar to koa-etag

Keywords

FAQs

Package last updated on 09 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc