Return to Snippet

Revision: 49413
at July 21, 2011 20:28 by theworldofdan


Initial Code
<?php
// Source: http://www.catswhocode.com/blog/10-life-saving-php-snippets
// Could be modified, I can't remember if I did

$offset = 60 * 60 * 24; // Cache for a day
header('Content-type: text/css');
header('Cache-Control: max-age=' . $offset . ', must-revalidate');
header('Expires: ' . gmdate ("D, d M Y H:i:s", time() + $offset) . ' GMT');
ob_start("compress");

function compress($buffer)
{
	/* remove comments */
	$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
	/* remove tabs, spaces, newlines, etc. */
	$buffer = str_replace(array("
", "\r", "\n", "\t", '  ', '    ', '    '), '', $buffer);
	return $buffer;
}

/* your css files */
include('base.css');
include('style.css');
include('typography.css');
include('forms.css');
include('jquery.fancybox-1.3.0.css');

ob_end_flush();

Initial URL
http://www.catswhocode.com/blog/10-life-saving-php-snippets

Initial Description

                                

Initial Title
Load multiple CSS files at once

Initial Tags

                                

Initial Language
PHP