Skip to content

Conversation

@alrra
Copy link
Member

@alrra alrra commented Sep 5, 2015

Changes:

  • Add server configurations to the .htaccess file that make Apache serve certain resources compressed.

    Right now, nothing served from https://html.spec.whatwg.org/ is compressed, e.g.:

    $ curl -sSLvv -H 'Accept-Encoding: gzip, deflate' https://html.spec.whatwg.org/ -o /dev/null
    
    *   Trying 208.113.236.128...
    * Connected to html.spec.whatwg.org (208.113.236.128) port 443 (#0)
    * TLS 1.0 connection using TLS_DHE_RSA_WITH_AES_256_CBC_SHA
    * Server certificate: *.whatwg.org
    * Server certificate: StartCom Class 2 Primary Intermediate Server CA
    * Server certificate: StartCom Certification Authority
    > GET / HTTP/1.1
    > Host: html.spec.whatwg.org
    > User-Agent: Mozilla/5.0 Gecko
    > Accept: */*
    > Accept-Encoding: gzip, deflate
    > 
    < HTTP/1.1 200 OK
    < Date: Sat, 05 Sep 2015 20:03:17 GMT
    < Server: Apache
    < Last-Modified: Sat, 05 Sep 2015 16:39:55 GMT
    < ETag: "7ccb43-51f02aa882cc0"
    < Accept-Ranges: bytes
    < Content-Length: 8178499
    < Access-Control-Allow-Origin: *
    < Strict-Transport-Security: max-age=31415926; includeSubDomains
    < Content-Type: text/html; charset=utf-8
    < 
    { [16384 bytes data]
    * Connection #0 to host html.spec.whatwg.org left intact

    In the case of the source file (https://html.spec.whatwg.org/), the saving will be as follows:

    original size:         8.18 MB
    gzipped size:          1.42 MB
    ──────────────────────────────
    reduction:             6.76 MB [82.6%]
    

    ⚠️ Notes:

    • mod_deflate needs to be enabled for this to take effect.
    • The <IfModule ... > checks are there to ensure that Apache won't try to run the enclosed configs if the required modules are not enabled.
  • Add server configurations to the .htaccess file that make Apache serve certain file types with the media type charset parameter set to UTF-8.

    ⚠️ Note: mod_mime needs to be enabled for this to take effect.

  • Make minor consistency improvements in .htaccess, namely:

    • Fix indentation.
    • For consistency, use Files instead of files.

Note: I had a quick chat with @annevk, and he told me that the Apache version used is: 2.2.22-14.

If I need to change anything, let me know. :)

@mathiasbynens
Copy link
Member

Note: this PR is based on https://github.com/h5bp/server-configs-apache/blob/master/dist/.htaccess. On servers that I manage, I use that as a global configuration file (*.conf), using .htaccess files only for custom overrides and site-specific settings.

Perhaps you could consider doing the same for the WHATWG servers? They’re really sensible defaults, and it would simplify the current .htaccess.

@annevk
Copy link
Member

annevk commented Sep 6, 2015

I added AddOutputFilterByType DEFLATE application/javascript application/json text/css text/html text/plain to a higher-level .htaccess. That seems to work well.

@annevk
Copy link
Member

annevk commented Sep 6, 2015

We probably want to not dictate encoding decisions so we should keep those. However, could we just add AddCharset below the encoding line we already have? I don't think there's much need for all the comments here.

@alrra
Copy link
Member Author

alrra commented Sep 6, 2015

I added AddOutputFilterByType DEFLATE application/javascript application/json text/css text/html text/plain to a higher-level .htaccess. That seems to work well.

@annevk Related commit removed.

Compression now works ✨

curl -sSLI -H 'Accept-Encoding: gzip, deflate' https://html.spec.whatwg.org 

HTTP/1.1 200 OK
Date: Sun, 06 Sep 2015 15:10:31 GMT
Server: Apache
Last-Modified: Sun, 06 Sep 2015 00:57:01 GMT
ETag: "7ccae8-51f099c4cd140"
Accept-Ranges: bytes
Vary: Accept-Encoding
-----> Content-Encoding: gzip
Access-Control-Allow-Origin: *
Strict-Transport-Security: max-age=31415926; includeSubDomains
Content-Type: text/html; charset=utf-8

higher-level `.htaccess

@annevk, @mathiasbynens Maybe there should be a repository with those configs?

However, could we just add AddCharset below the encoding line we already have?

Done.

I don't think there's much need for all the comments here.

Comments removed.

Let me know if I need to change anything else, and thanks for reviewing!

@annevk
Copy link
Member

annevk commented Sep 6, 2015

Maybe there should be a repository with those configs?

Yeah I think that might be useful. They're also spread around a bit as the subdomains are divided to some extent per user.

Any ideas for what we should call this and how to organize it?

There's also some scripts on the server that take care of synchronization with the repositories we might want to host somewhere so folks can suggest improvements.

.htaccess Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs moving.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@annevk Done.

@annevk
Copy link
Member

annevk commented Sep 6, 2015

Could you also squash the commits? Or I can do it while merging. Doesn't seem worth the two tweets it'll generate.

* Fix indentation.

* Add configurations to make Apache serve certain file types with the
  media type `charset` parameter set to `UTF-8`.

* For consistency, use `Files` instead of `files`.
  (See also: http://httpd.apache.org/docs/current/mod/core.html#files)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Ref: #112
@alrra
Copy link
Member Author

alrra commented Sep 6, 2015

Could you also squash the commits?

@annevk Done.

@annevk annevk merged commit 323b4cc into whatwg:master Sep 6, 2015
@alrra alrra deleted the improve-server-configs branch September 6, 2015 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants