Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

do-not-cache

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

do-not-cache

set HTTP response headers to prevent caching

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
771
decreased by-19.44%
Maintainers
1
Weekly downloads
 
Created
Source
var assert = require('assert')
var http = require('http')

var doNotCache = require('./')

var receivedResponse = false

http.createServer()
.on('request', function (request, response) {
  doNotCache(response)
  response.end()
})
.listen(0 /* random high port */, function () {
  var server = this
  var port = server.address().port
  http.request({port: port})
  .on('response', function (response) {
    var headers = response.headers
    receivedResponse = true
    // RFC 1945 (HTTP 1.0)
    assert(headers['pragma'] === 'no-cache') // Section 10.12
    assert(headers['expires'] === '0') // 10.7
    // RFC 2616 (HTTP 1.1)
    assert(
      headers['cache-control']
      .includes('no-cache')
    ) // Section 14.9.1
    assert(
      headers['cache-control']
      .includes('no-store')
    ) // 14.9.2
    assert(
      headers['cache-control']
      .includes('must-revalidate')
    ) // 14.9.4
    server.close()
  })
  .end()
})

process.on('exit', function () {
  assert(receivedResponse === true)
})

FAQs

Package last updated on 03 Sep 2016

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