h5bp / html5-boilerplate

A professional front-end template for building fast, robust, and adaptable web apps or sites.

Home Page:https://html5boilerplate.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong mod_headers lines?

DanielRuf opened this issue · comments

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

Bug reports

It looks like there is mod_headers used but it should be probably mod_rewrite:

https://github.com/h5bp/html5-boilerplate/blob/main/dist/.htaccess#L942
https://github.com/h5bp/html5-boilerplate/blob/main/dist/.htaccess#L1000

the htaccess file is managed at https://github.com/h5bp/server-configs-apache/ If you're having an issue, that's the place

I will point out, before you open an issue over there, that Apache's own gzip compression documentation (which is referenced in the section of our htaccess you link to) uses mod_headers

https://httpd.apache.org/docs/current/mod/mod_deflate.html#precompressed

<IfModule mod_headers.c>
    # Serve gzip compressed CSS and JS files if they exist
    # and the client accepts gzip.
    RewriteCond "%{HTTP:Accept-encoding}" "gzip"
    RewriteCond "%{REQUEST_FILENAME}\.gz" -s
    RewriteRule "^(.*)\.(css|js)"         "$1\.$2\.gz" [QSA]

    # Serve correct content types, and prevent mod_deflate double gzip.
    RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1]
    RewriteRule "\.js\.gz$"  "-" [T=text/javascript,E=no-gzip:1]


    <FilesMatch "(\.js\.gz|\.css\.gz)$">
      # Serve correct encoding type.
      Header append Content-Encoding gzip

      # Force proxies to cache gzipped &
      # non-gzipped css/js files separately.
      Header append Vary Accept-Encoding
    </FilesMatch>
</IfModule>

https://github.com/h5bp/server-configs-apache/blob/main/dist/.htaccess#L1000

 # <IfModule mod_headers.c>
 #    RewriteCond %{HTTP:Accept-Encoding} gzip
#     RewriteCond %{REQUEST_FILENAME}\.gz -f
#     RewriteRule \.(css|ics|js|json|html|svg)$ %{REQUEST_URI}.gz [L]

#     # Prevent mod_deflate double gzip
#     RewriteRule \.gz$ - [E=no-gzip:1]

#     <FilesMatch "\.gz$">

#         # Serve correct content types
#         <IfModule mod_mime.c>
#             # (1)
#             RemoveType gz

#             # Serve correct content types
#             AddType text/css              css.gz
#             AddType text/calendar         ics.gz
#             AddType text/javascript       js.gz
#             AddType application/json      json.gz
#             AddType text/html             html.gz
#             AddType image/svg+xml         svg.gz

#             # Serve correct content charset
#             AddCharset utf-8 .css.gz \
#                              .ics.gz \
#                              .js.gz \
#                              .json.gz
#         </IfModule>

#         # Force proxies to cache gzipped and non-gzipped files separately
#         Header append Vary Accept-Encoding

#     </FilesMatch>

#     # Serve correct encoding type
#     AddEncoding gzip .gz

# </IfModule>

Regarding deflate / gzip, well in the docs they use Header append Content-Encoding gzip so there mod_headers makes sense there.

But I see no Header ... in your blocks.

At least it is somehoe confusing that there is no extra ifmodule for mod_rewrite in these blocks.

Sorry, it didn't appear to be a valid issue so I closed it. I didn't want to add an issue for another maintainer. That code is 3+ years old so something that fundamental seems like it would have shaken out by now. Especially since it matches the Apache documentation. I apologize if it's a valid issue.