HTML Guide for expires
Expires is not a valid value for the http-equiv attribute in HTML5.
The http-equiv attribute is used with the <meta> tag to configure the HTTP headers of the web page. In HTML5, the allowed values for http-equiv include content-type, default-style, refresh, and security-related headers like Content-Security-Policy. The Expires header is an HTTP header typically set in server configurations or via server-side scripting, not through HTML. To control page caching, consider using server-side headers for Expires or use the cache-control setting if supported by your server.
Here’s how you might correct an HTML document using valid http-equiv values and manage caching through server-side configurations:
Example of Valid HTML <meta> Tags:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Example Page</title>
</head>
<body>
<h1>Welcome to My Website</h1>
</body>
</html>
Example of Setting Expires at Server Level:
If you’re using Apache, you might set Expires in a .htaccess file:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html "access plus 1 week"
</IfModule>
For Nginx, such settings would be in the server’s configuration file:
location ~* \.html$ {
expires 7d;
}
Using these methods, you ensure compliance with HTML5 standards by handling HTTP headers correctly.