Page 1 of 1
When to include ?
Posted: Sun Nov 03, 2002 8:55 pm
by liquidchild
I am creating a web site that does not use frames and only uses css, however i have the problem that when i go to constuct a .php page from several other .php pages there can rightly only be one <head></head> section, this is not a problem, however in each .php file there is the corresponding css file for that pages layout, so i was wondering without have to create one big css file or without having to include all css files by default if there was some way of writing in one file say header.php (which would include the <head></head> tags, thus requires to include the <link> tags for the css) what css files to include, now this may start to get messy so any suggestions are welcome!
Thanks in advance
Posted: Mon Nov 04, 2002 1:45 am
by Heavy
Since css files are cached by the browser and proxies, unless you control them with PHP and send anti-cache headers, creating one big css is not really bad. However, if you expect visitors NOT to view more than one
kind of page, maybe it would be an unnecessary load for the server if you make one big css-file, which holds styles for the whole site.
You could do every page like this:
Code: Select all
<?
// Make sure that there is no output (including space, newline) before <?. Otherwise, sending headers won't work for you
//If you want to prevent caching in proxies and browsers, do the following:
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
//Use this in the include if you like:
$cssfile="path/to/specific.css";
//here's your top-of-page include file:
include "path/to/common_header.php";
?>
<!--whatever content of a specific file-->