Forum Moderators: phranque

Message Too Old, No Replies

Any advantage to putting response headers in Apache than HTML?

         

csdude55

7:42 pm on Apr 18, 2024 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have a handful of response headers in my HTML that are on every page of every site on the server:

<meta name="language" content="English">
<meta name="distribution" content="Global"> <!-- should probably be "Local" in my case, but I don't trust it -->
<meta name="robots" content="All">
<meta name="referrer" content="no-referrer-when-downgrade">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">


I honestly don't even know what half of them do, if anything! LOL These were mostly set up years ago, if not decades ago.

Is there an advantage to moving them to Apache, other than saving 330 bytes per page?

lucy24

9:25 pm on Apr 18, 2024 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is there any advantage...

Better yet: half of them can simply be removed.

language: shift this to the overall html tag in the form
<html lang="en">
Yes, we all know that G### simply ignores any and all <lang> declarations, but that doesn't mean we should withhold the information from human browsers and others that do use it.

distribution: Sorry, no idea. Someone else (phranque?) may know.

robots: unless you're saying something other than the default, this isn't needed at all. The declarations "noindex" and/or "nofollow" can go on the individual page, if it only applies to one, or in the config/htaccess for the whole directory, if the same rule applies to all of it.

referrer: Again, no idea. But the content kinda sounds like something modern browsers do by default anyway.

content-type: Not needed in HTML 5 (opening declaration <html> and-that's-all, with language optional)

viewport: keep this unless there exists a reliable once-and-for-all Apache declaration, in which case I should upgrade my own site

For comparison purposes, most of my <head> sections start like this (copy-and-paste from the boilerplate that I use in any new page):
<!DOCTYPE HTML>
<html lang = "en">
<head>
<meta charset = "UTF-8">
<title>blahblah</title>
<meta name = "description" content = "blahblah">
<meta name = "viewport" content = "width=device-width, initial-scale=1">
<link rel = "stylesheet" type = "text/css" [and so on depending on page and directory: generally two, sometimes three shared stylesheets in addition to page-specific styles]
<style>
</style>
</head>

Special note about charset: If you set a charset in config/htaccess, this will override anything set in the page itself. (Yes, this is counterintuitive, because most things work the other way around) But I like to also set it on each page, to ensure that things are read correctly if, say, someone temporarily downloads the page for offline study. If your <title> contains any non-ASCII characters, make sure the charset declaration, if any, comes before the title.