function advagg_missing_set_farfuture_headers in Advanced CSS/JS Aggregation 7.2
Set various headers so the browser will cache the file for a long time.
1 call to advagg_missing_set_farfuture_headers()
- advagg_missing_send_saved_file in ./
advagg.missing.inc - Send the css/js file to the client.
File
- ./
advagg.missing.inc, line 373 - Advanced CSS/JS aggregation module.
Code
function advagg_missing_set_farfuture_headers() {
// Hat tip to the CDN module for the far future headers.
//
// Browsers that implement the W3C Access Control specification might refuse
// to use certain resources such as fonts if those resources violate the
// same-origin policy. Send a header to explicitly allow cross-domain use of
// those resources. This is called Cross-Origin Resource Sharing, or CORS.
header("Access-Control-Allow-Origin: *");
// Remove all previously set Cache-Control headers, because we're going to
// override it. Since multiple Cache-Control headers might have been set,
// simply setting a new, overriding header isn't enough: that would only
// override the *last* Cache-Control header. Yay for PHP!
if (function_exists('header_remove')) {
header_remove('Cache-Control');
header_remove('ETag');
header_remove('Set-Cookie');
}
else {
header('Cache-Control:');
header('Cache-Control:');
header('ETag:');
header('ETag:');
header('Set-Cookie:');
header('Set-Cookie:');
}
// Set a far future Cache-Control header (52 weeks), which prevents
// intermediate caches from transforming the data and allows any
// intermediate cache to cache it, since it's marked as a public resource.
if (variable_get('advagg_resource_hints_use_immutable', ADVAGG_RESOURCE_HINTS_USE_IMMUTABLE)) {
header('Cache-Control: max-age=31449600, public, immutable');
}
else {
header('Cache-Control: max-age=31449600, public');
}
}