File Meta Data for GZIP

Matthew B
Matthew B used Ask the Experts™
on
I am using digital ocean and keycdn to optimize delivery of static assets for a client.

I am editing the content meta data to enable gzip compression for certain larger files.

I have javascript that i obviously dont want to be downloaded to the users computer but loaded by the browser, do i need to set the content-disposition? And do i set it to inline or do i just leave it blank?

Here are the settings i have:

Content-Type: text/javascript
Cache-Control: 60
Content-Encoding: Gzip
Content-Disposition: Inline? Blank?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
David FavorFractional CTO
Distinguished Expert 2018

Commented:
This occurs at the Webserver level.

If you're using Apache on major Distros, like Ubuntu, this is setup automatically.

You'll find the default deflate module config file somewhere like /etc/apache2/mods-enabled/deflate.conf or similar (Distro dependent).

Use https://checkgzipcompression.com to verify GZIP compression is working correctly for site in question.
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Tip: There's no point using CDNs anymore.

You should be using HTTP/2, which fires off all requests in parallel for all site assets.

If you check CDN speed + stability over long periods of time, likely you'll never use a CDN again.

You'll be surprised just how many problems CDNs actually cause... contrary to popular myth, promulgated by people who believe CDN company marketing hype rather than doing continuous testing.

Hint: The more widely known a CDN, usually these have worst speed + stability.
David FavorFractional CTO
Distinguished Expert 2018

Commented:
You can also do this on the command line...

imac> curl -I -H 'Accept-Encoding: deflate,gzip,br' https://davidfavor.com
HTTP/2 200 
date: Mon, 10 Dec 2018 16:02:16 GMT
server: Apache/2.4.33 (Ubuntu)
strict-transport-security: max-age=63072000; preload
last-modified: Tue, 03 Jul 2018 15:37:00 GMT
accept-ranges: bytes
cache-control: max-age=2592000
expires: Wed, 09 Jan 2019 16:02:16 GMT
vary: Accept-Encoding
content-encoding: gzip     <<<<<<< compression type shown here
x-edge-location: YUL
content-length: 4480
content-type: text/html

Open in new window


Be sure to include br to test for brotli compression as this is becoming common place.

In fact... sigh... I notice, I've missed enabling brotli on the Apache instance serving the site above.
Matthew BHack

Author

Commented:
Hi,

Its weird because in nginx conf file i have the appropraite enable gzip stuff all set up by gtmetrix is still saying that a slew of files are not being compressed and its adding 40 percent to my page size.

The static files wouldnt be served by my webserver if they are coming from my edge servers via cdn no ? Or you saying that the file meta data would inherit from my nginx server?

Also if were expecting a lot of heavy traffic wont cdn help by taking load off of our server? Http2 would keep the burden on our single server
Hack
Commented:
I did not use DO CDN for this as it had many issues and also i was adding the wrong meta data, where it expected the cache control time i was putting max-age="time" but i did not needd the max-age key, only the value.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial