Ali Shakiba
Ali Shakiba

Reputation: 21277

Is it safe to serve pre-gziped content?

Is it safe to serve pre-gziped content? Does every browser support it?

Upvotes: 0

Views: 123

Answers (2)

Jeff
Jeff

Reputation: 736

No, a browser will specify in the header

Accept-Encoding: gzip, deflate

when it supports gzipped content.

Even if the browser does support it there may be a firewall in between that removes the Accept-Encoding and refuses any gzipped content (so it can easily scan it for viruses)

Therefore check for Accept-Encoding (most webservers will do that automatically for you).

Upvotes: 1

Chris Eberle
Chris Eberle

Reputation: 48795

Yes, but you need to append a header so that the client knows it's gzipped. In PHP you would do it like this:

header("Content-Encoding: gzip");

However be aware that not every browser out there supports this fully (IE has a reputation of being rather horrible at it, although I believe this has been addressed in more recent versions).

Upvotes: 0

Related Questions