There are a variety of answers to this question which tackle it via the admin console. I would like to enable this via Glassfish's XML configuration but have not found any documentation regarding this feature.
You can set it in the domain.xml
under network-config
--> protocols
Example:
<protocol name="http-listener-1">
<http default-virtual-server="server" max-connections="250"
compressable-mime-type="text/html,text/xml,text/plain,text/javascript" compression="on" compression-min-size-bytes="4096">
<file-cache></file-cache>
</http>
</protocol>