public function video_amazon_s3::updateAllExpiresHeaders in Video 6.5
Update Expires headers on currently-uploaded files.
File
- plugins/
video_s3/ video_s3.lib.inc, line 168 - Class file to handle amazon s3 transfers.
Class
Code
public function updateAllExpiresHeaders() {
// First, make sure this is a good time to do this. It doesn't make much
// sense to do this more often than the Expires offset.
$expires_offset = variable_get('amazon_s3_expires_offset', 604800);
if ($expires_offset === 'none' || $expires_offset === 0) {
return;
}
if (variable_get('amazon_s3_expires_last_cron', 0) + $expires_offset > time()) {
return;
}
$active = db_query('SELECT bucket, filename, filepath, filemime FROM {video_s3} WHERE status = %d', VIDEO_S3_COMPLETE);
$permission = variable_get('amazon_s3_private', FALSE) ? AmazonS3::ACL_PRIVATE : AmazonS3::ACL_PUBLIC;
$headers = array(
'Expires' => gmdate('r', time() + $expires_offset),
);
// Note that Cache-Control headers are always relative values (X seconds
// in the future from the point they are sent), so we don't need to update
// them regularly like we do with Expires headers. However, if we don't
// send one, the one that is set (if any) will be deleted. (Also, if the
// human has changed this setting on the administration page, we want to
// update video info accordingly.)
// @todo: Logic problems: This only updates when expires headers update…
// Might want to find a way so that these update immediately when the
// admin settings form is submitted.
$cc = variable_get('amazon_s3_cache_control_max_age', 'none');
if ($cc !== 'none') {
$headers['Cache-Control'] = 'max-age=' . $cc;
}
while ($file = db_fetch_object($active)) {
$this
->update_headers($file, $permission, $headers);
}
variable_set('amazon_s3_expires_last_cron', time());
}