Skip to content

Commit

Permalink
Merge pull request #55 from RajeshHegde/feature/caching
Browse files Browse the repository at this point in the history
Support caching headers, metadata, expiry
  • Loading branch information
Mahmoud Zalt committed May 26, 2015
2 parents 51060f2 + 3ef3452 commit 59414c6
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Vinelab/Cdn/Providers/AwsS3Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ public function upload($assets)
'ACL' => $this->acl,
// the permission of the file

'CacheControl' => $this->default['providers']['aws']['s3']['cache-control'],
'MetaData' => $this->default['providers']['aws']['s3']['metadata'],
"Expires" => $this->default['providers']['aws']['s3']['expires']

]));
} catch(S3Exception $e) {
$this->console->writeln("<fg=red>Error while uploading: ($file->getRealpath())</fg=red>");
Expand Down
24 changes: 24 additions & 0 deletions src/config/cdn.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,30 @@
'version' => '',
],

/*
|--------------------------------------------------------------------------
| Add metadata to each s3 file
|--------------------------------------------------------------------------
| Add metadata to each s3 file
*/
'metadata' => [],

/*
|--------------------------------------------------------------------------
| Add expiry data to file
|--------------------------------------------------------------------------
| Add expiry data to file
*/
'expires' => gmdate("D, d M Y H:i:s T", strtotime("+5 years")),

/*
|--------------------------------------------------------------------------
| Add browser level cache
|--------------------------------------------------------------------------
| Add browser level cache
*/
'cache-control' => 'max-age=2628000',

],

],
Expand Down
7 changes: 6 additions & 1 deletion tests/Vinelab/Cdn/CdnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ public function testPushCommand()
'use' => false,
'cdn_url' => '',
'version' => '',
]
],
'metadata' => [],

'expires' => gmdate("D, d M Y H:i:s T", strtotime("+5 years")),

'cache-control' => 'max-age=2628000',
],
],
],
Expand Down
20 changes: 20 additions & 0 deletions tests/Vinelab/Cdn/Providers/AwsS3ProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public function testInitializingObject()
'cdn_url' => null,
'version' => null,
],
'metadata' => [],

'expires' => gmdate("D, d M Y H:i:s T", strtotime("+5 years")),

'cache-control' => 'max-age=2628000',
],
],
],
Expand Down Expand Up @@ -119,6 +124,11 @@ public function testUploadingAssets()
'cdn_url' => null,
'version' => null,
],
'metadata' => [],

'expires' => gmdate("D, d M Y H:i:s T", strtotime("+5 years")),

'cache-control' => 'max-age=2628000',
],
],
],
Expand Down Expand Up @@ -153,6 +163,11 @@ public function testUrlGenerator()
'cdn_url' => null,
'version' => null,
],
'metadata' => [],

'expires' => gmdate("D, d M Y H:i:s T", strtotime("+5 years")),

'cache-control' => 'max-age=2628000',
],
],
],
Expand Down Expand Up @@ -187,6 +202,11 @@ public function testEmptyUrlGenerator()
'cdn_url' => null,
'version' => null,
],
'metadata' => [],

'expires' => gmdate("D, d M Y H:i:s T", strtotime("+5 years")),

'cache-control' => 'max-age=2628000',
],
],
],
Expand Down

0 comments on commit 59414c6

Please sign in to comment.