Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Hot answers tagged

49

Basically every browser nowadays supports deflate/gzip. This page lists many browsers and version numbers. Here's a summary plus some newer browsers: Netscape 6+ (Netscape 4-5 does, but with some bugs). Internet Explorer 5.5+ (July 2000) and IE 4 if set to HTTP/1.1. Opera 5+ (June 2000) Lynx 2.6+ (some time before 1999) Firefox 0.9.5+ (October 2001) Chrome ...


32

Updated answer for 2017: Yes. The size column in the Network tab in Chrome Developer Tools has both the compressed and uncompressed size, for gzip, brotli and whatever comes in future. Eg: Here the compressed size is 242 KB, the uncompressed size is 1.1 MB To see both, ensure you have Devtools showing large request rows. It's the first icon in "View" ...


14

As covered here, GitHub Pages is served with Nginx and automatically gzip's content. You can confirm gzip compression for your site by checking the HTTP headers with online tools like this one. Enter the URL to a webpage or resource, and type in gzip under "Accept-Encoding" to indicate that the HTTP client (i.e., the online testing tool in this case) ...


9

Update for 2017 When using large icons, the chrome dev tools show a before and after compression size in the network tabs. I confirmed by switching gzip off and on on my webserver.


7

Check here: https://stackoverflow.com/questions/9249243/how-to-disable-apache-gzip-compression-for-some-media-files-in-htaccess-file It's possible, but looks like it will disable gzip for the whole website. Keep in mind that you are telling PHP not to gzip, but Apache may still be gzipping so this should sort it, but check Apache config. RewriteRule ^(.*)$...


7

I have decided to serve only gzipped version of my pages If you're only serving files that you've compressed using gzip, then using Vary: Accept-Encoding will be of no benefit since there won't be uncompressed copies of the files to serve to clients that don't send Accept-Encoding: gzip in the HTTP request. Most clients these days do send this, so you ...


6

A simpler one that also works: SetEnv no-gzip 1 The line you were using disables PHP's compression. The no-gzip env variable, on the other hand, disables Apache compression.


6

Yes, Amazon Cloudfront can now serve GZip'ed / HTML Compressed content to end users fairly easily. This used to be rather hard, but Amazon added this to Cloudfront around November 2010. What you are looking for is called "custom origin". The gist of it is: You set up your own web server, and configure this server to correctly compress content for ...


6

Why do you want to serve those static assets with a gz extension at all? Despite being the common indicator for ages, file extensions are actually an inferior and inaccurate mechanism to communicate a MIME type in the first place: ideally, web resources should be entirely agnostic to file extensions and only communicate their content by means of appropriate ...


5

I know this is an old question, but it shows up early on google so I thought I would answer it. You can now enable gzip on GoDaddy by adding the following to the .htaccess in your root directory. AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript Source - GoDaddy Support


5

Another way to accomplish this is with cURL: curl -i -H "Accept-Encoding: gzip" http://someurl.com | wc -c versus curl -i http://someurl.com | wc -c The number shown after each command is the number of bytes that crossed the wire.


5

You can add it to the existing .htaccess file your Wordpress creates for SE friendly URLs. If you don't have an htaccess file from Wordpress then you can create your own with the GZIP code in it and it won't break Wordpress at all.


5

Apache uses deflate which is responsible for compressing the data into gzip formatting and sending it to the client, its important to note that the compress happens as the data is requested and not before. You should familiarize yourself with mod_deflate as well ensure its installed and enabled correctly. Formats such as MP3 are not ideal for gzip since ...


5

This is a design limitation: The file size must be between 1,000 and 10,000,000 bytes. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html Compressing files is resource-intensive, so the designers of CloudFront placed an upper bound on the size of files that CloudFront will spend resources compressing on-...


4

You'll want to look into mod_deflate (http://httpd.apache.org/docs/2.2/mod/mod_deflate.html) Depending on the operating system, but on most Linux-based systems you can do the following: edit the configuration file httpd.conf or similar) if you have a VirtualHost container, add this: SetOutputFilter DEFLATE you can also set directory-specific compression: &...


4

Put these lines in your .htaccess and PageSpeed Insights will see your gzip compression: <IfModule mod_deflate.c> <FilesMatch "\.(html|php|txt|xml|js|css)$"> SetOutputFilter DEFLATE </FilesMatch> </IfModule> It works for my sites.


3

Which option should I choose and why? I would probably choose the second option, but add to that list text/css and text/javascript. Basically you want to compress any text-based content, but not content like images, as these are already compressed. I have omitted the type="text/css" attributes from all CSS references, as well as the type="text/...


3

Does CloudFlare gzip resources? Yes, CloudFlare gzips resources that pass through our network. We also gzip items based on the browser's useragent to help speed up page loading time. If you're already using gzip we will honor your gzip settings as long as you're passing the details in a header from your web server for the files. Source: https://...


3

Quoting @cyberx86 over at ServerFault (who you should go and vote up): The .xml.gz filetype may be defined as being an xml file (e.g. with forcetype in a filesmatch block) - which would cause Apache to match it to the type above. I think you can get around that by adding an exception, above it: SetEnvIfNoCase Request_URI ".xml.gz$" no-gzip dont-...


3

You're talking about the benefits to your bandwidth costs, but then also comparing the performance of the page load in a browser. They're two different things. Anytime you gzip a request, something has to actually do the compression (in your case, the F5) and the client (or technically proxies) has to handle the decompression. This can add more latency to ...


3

It seems you're not the only one having such problems, look here and here, there are some suggestions on fixes in these threads - have you ruled these out already? Are you in a multi web server environment? Could one of the servers in the pool have a corrupted copy of the image? Interestingly it's not limited to the background image, and the corruption ...


3

Yep. Just add more types: AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript application/x-font-ttf


3

There are no SEO benefits to serving a compressed XML sitemap over serving one that is not compressed. The advantage of compression is simply to save bandwidth and the time it takes to download. (If your sitemap is huge.) Note that the limits for the size of the sitemap are the uncompressed size (ie. 50MB uncompressed for Google).


3

it seems to me, the archiving procedure lets the tarball grow and if the tarball becomes (together with all other data) bigger then the available place in your booked hosting, the server kills the process. You will be forced firstly to download all of your data, and archive them locally. Could it be true?


2

The first thing I noticed when I looked at your page in Firebug is that some of your images (specifically this one, which toomanyairmiles already posted a screenshot of, and this other one) are simply huge — the first one is 4.2 megabytes! When I first loaded the page, the huge image was corrupted, more or less like in toomanyairmiles's screenshot. ...


2

The output of PHP files is HTML. That HTML will be compressed using the code in this question: AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css application/javascript application/json That's all you need to do (assuming mod_deflate is enabled for Apache).


2

Won't work with IE6 browsers, but here's how WordPress users do it. http://perfectionlabstips.wordpress.com/2008/12/30/serving-gzipped-gz-files-as-compressed-css-javascript-html-content/ Their examples are for CSS and JavaScript, but it's easily applicable for .html from the samples. They show you how to detect for browsers that won't work and keep an ...


2

besides Dan's answer, depending on your static-site generators, there can be some plugins that make the compressed .gz-ed version offline while generating the site. By that way, your server can serve those gz-ed pages directly. For example, Pelican users can use gzip_cache. For Jekyll, there's jekyll-press,


2

There is no difference between the two ways you describe of gzipping a sitemap.xml for search engines. The important thing is to just make sure your sitemap.xml is gzipped, to save bandwidth for website servers and search engines, even more if your sitemap.xml file size is big.


2

You don't have to worry about gzip. It's the browser's job to uncompress them and there isn't anything you have to do differently. Short read: https://developers.google.com/speed/articles/gzip


Only top voted, non community-wiki answers of a minimum length are eligible