Use response headers from Asset Manager when proxying to S3
Use response headers from Asset Manager when proxying to S3

This is a follow-up to the PR in which we made it possible to configure
the Asset Manager to proxy asset requests to S3 via Nginx [1]. Since
then we've merged an Asset Manager PR [2] which allows us to divert a
percentage of asset request traffic to be proxied to S3. We plan to roll
this out gradually while carefully monitoring the load on and
performance of the production stack.

Unfortunately Nginx and S3 use different algorithms to generate an ETag
response header and, since the S3 copy of each asset has a different
last modified time, the Last-Modified response header values are
different too. So in order to avoid unnecessary cache invalidation and
hence confound our monitoring of load & performance, we've made a change
[3] to the Asset Manager Rails app to generate Nginx-esque ETag &
Last-Modified response headers.

The changes to the Asset Manager Nginx config in this commit store the
response header values from Rails and then add them to the response from
S3 before the response is sent back to the user thus avoiding the
unnecessary cache invalidation mentioned above.

We're also about to make another change to the Asset manager Rails app
[4] to send Cache-Control, Content-Disposition & Content-Type headers
when instructing Nginx to proxy requests to S3. The idea behind this is
to avoid duplicate Cache-Control headers ending up in the response to
the user and to make the Rails app the canonical source for response
headers. Fortunately Nginx copies the Cache-Control &
Content-Disposition headers into the proxied response by default, but we
need to explicitly store and set the Content-Type header in the same way
as we are doing for ETag & Last-Modified.

[1]: #6280
[2]: alphagov/asset-manager#152
[3]: alphagov/asset-manager#157
[4]: alphagov/asset-manager#164

alphagov/govuk-puppet,alphagov/govuk-puppet,alphagov/govuk-puppet,alphagov/govuk-puppet,alphagov/govuk-puppet,alphagov/govuk-puppet