Gzip Drupal Views JSON output

Submitted by kentr on 06/26/2016, 12:39


In a recent site profiling, I found that the output from a D8 Views REST export wasn't getting gzipped.

The Chrome Audit reported that gzipping would reduce the payload size by ~ 2/3 (~69.4 KB).


Add the following to .htaccess:

# Force enable compression of any JSON output.
# mod_deflate will only compress if client supports it.
# https://httpd.apache.org/docs/trunk/mod/mod_deflate.html
# Don't use this with reverse proxies, lest the compressed response
# get cached for all clients.
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE application/json application/hal+json


Add new comment