Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Add JSON gzip compression
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Zanona committed Feb 9, 2015
1 parent 8807ede commit 99a7dea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ module.exports = function(deployDir, amazonBucket, amazonKey, amazonSecret) {
getS3Params: function (localFile, stat, callback) {
console.log('>', path.relative(tmpDir, localFile));
var p = {};
if (localFile.match(/\.(html|js|css)/)) {
if (localFile.match(/\.(html|js|json|css)/)) {
p.ContentEncoding = 'gzip';
p.Metadata = { 'raw-content-length': sizeMap[localFile] };
}
if (localFile.match(/\.(html)/)) {
p.CacheControl = 'no-cache';
}
if (localFile.match(/\.(js|css)/)) {
if (localFile.match(/\.(js|json|css)/)) {
p.CacheControl = 'max-age=31536000';
}
if (localFile.match(/\.(jpg|png|gif)/)) {
Expand All @@ -51,7 +51,7 @@ module.exports = function(deployDir, amazonBucket, amazonKey, amazonSecret) {
exec('cp -r ' + deployDir + '* ' + tmpDir);

fs.readdirSync(tmpDir).forEach(function (f) {
if (!f.match(/\.(html|js|css)$/)) { return; }
if (!f.match(/\.(html|js|json|css)$/)) { return; }
f = path.resolve(tmpDir, f);
var size = exec('wc -c <"' + '/' + f + '"');
sizeMap[f] = size.replace(/\s/g, '');
Expand Down

0 comments on commit 99a7dea

Please sign in to comment.