File Meta Data for GZIP

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?
Matthew BHackAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
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 FavorLinux/LXD/WordPress/Hosting SavantCommented:
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 FavorLinux/LXD/WordPress/Hosting SavantCommented:
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 BHackAuthor 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
Matthew BHackAuthor 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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.