Re:Architecting Websites for the HTTP/2 Era
by richardwhiuk on Tuesday May 12, 2015 @02:06PM
(#9533680)
It's quite depressing that we can't have both compression and encryption at the same time - text is very compressible - particularly HTML markup...
[ Parent
| on HN ]
Theoretically, you can, as long as any secrets within the response body are represented as a "literal" (that is, uncompressed) within the compressed stream.
In practice, there isn't a way I know of to mark the relevant parts of the response body so that the compression, which is usually done as a separate post-processing step, will know to avoid compressing these parts of the stream. And it would be very fragile; forgetting to mark a secret as "do not compress this" would work perfectly fine but reintroduce the vulnerability.
Simply enough in HTTP2: lift out the relevant parts of the response body—turn them into separate resources and refer to them in the original object by their URL. When the client then requests those dependent objects, deliver them uncompressed. (And server-hint/push the dependent objects if you can, of course.)
Re:Architecting Websites for the HTTP/2 Era
by joeyespo on Wednesday May 13, 2015 @09:20AM
(#9538643)
Could the order be reversed, encrypting first then compressing second?
So only compress when sending over the wire?
You could, but you wouldn't compress much.
Encrypted data is supposed to look random, and as a consequence, it tends to compress very poorly.
Interesting. I was afraid that'd be the answer. Thanks for the reply.