Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
unreleased
==========

* Match `Cache-Control: no-transform` directive case-insensitively

1.8.1 / 2025-07-17
==========

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var hasBrotliSupport = 'createBrotliCompress' in zlib
* Module variables.
* @private
*/
var cacheControlNoTransformRegExp = /(?:^|,)\s*?no-transform\s*?(?:,|$)/
var cacheControlNoTransformRegExp = /(?:^|,)\s*?no-transform\s*?(?:,|$)/i
var SUPPORTED_ENCODING = hasBrotliSupport ? ['br', 'gzip', 'deflate', 'identity'] : ['gzip', 'deflate', 'identity']
var PREFERRED_ENCODING = hasBrotliSupport ? ['br', 'gzip'] : ['gzip']

Expand Down
17 changes: 17 additions & 0 deletions test/compression.js
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,23 @@ describe('compression()', function () {
.expect(200, 'hello, world', done)
})

;['No-Transform', 'NO-TRANSFORM', 'public, No-Transform, max-age=60'].forEach(function (value) {
it('should not compress response when "Cache-Control: ' + value + '"', function (done) {
var server = createServer({ threshold: 0 }, function (req, res) {
res.setHeader('Cache-Control', value)
res.setHeader('Content-Type', 'text/plain')
res.end('hello, world')
})

request(server)
.get('/')
.set('Accept-Encoding', 'gzip')
.expect('Cache-Control', value)
.expect(shouldNotHaveHeader('Content-Encoding'))
.expect(200, 'hello, world', done)
})
})

it('should not set Vary headerh', function (done) {
var server = createServer({ threshold: 0 }, function (req, res) {
res.setHeader('Cache-Control', 'no-transform')
Expand Down
Loading