Character case in HTML tags
What's the rule for character casing in html tags?
I have a situation where I need to force no caching on a site of mine. I have been using all lower case for all html tags and attributes (being under the impression that it's case insensitive). I haven't had any issued from this, until now.
I have found that the f开发者_运维问答ollowing works on IE7:
<META HTTP-EQUIV="Expires" CONTENT="-1">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
While this does not:
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Pragma" content="no-cache">
FYI I am using PHP and also included the following, but it does not seem to work without the HTML meta tag as well:
header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" );
header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
header( "Cache-Control: no-cache, must-revalidate" );
header( "Pragma: no-cache" );
header("Content-Type: text/html; charset=UTF-8");
EDIT (Added): We have the following doc type (I must admit I am not leet enough to know what this means or how relevant it is)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Have you tried another version of IE? HTML is not case sensitive while XHTML is. Here is what W3schools says about HTML.
HTML Tip: Use Lowercase Tags
HTML tags are not case sensitive:
means the same as
. Many web sites use uppercase HTML tags.
W3Schools use lowercase tags because the World Wide Web Consortium (W3C) recommends lowercase in HTML 4, and demands lowercase tags in future versions of (X)HTML.
A post at codingforums by freedom_razor states that IE7 doesn't like lowercase meta tags. Maybe you could use javascript to detect the browser and set the meta tags accordingly?
Well... the META tags shouldn't really have no effect at all, because you are already sending real HTTP headers, which should override the headers specified as meta tags (HTTP-EQUIV is what the name says - substitute for HTTP headers when they aren't available).
Also... in HTTP header you say "Expires" = "Mon, 20 Dec 1998 01:00:00 GMT", but in meta tag you specify that "Expires" = "-1". So you aren't really sure what you want the Expires value to be?
Besides that: cache control should be achieved with HTTP headers alone - how else can you control how images are cached (there are not meta-tags in image files).
精彩评论