mitodl / mitxpro

BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

HTTP response for CMS images missing etag, last-modified #2486

Closed pdpinch closed 1 year ago

pdpinch commented 1 year ago

Comparing the HTTP response headers between mitxonline and xPRO, it seems like xPRO is missing etag and last-modified headers, which are important for effective caching, both in the CDN and in the client.

example mitxonline:

% curl -I "https://mitxonline.mit.edu/media/original_images/8.01.2x_courseImage_435p-244p.png?v=50a30ec2256f4ebb8ae26b8904f1fab41fd36650"
HTTP/2 200 
x-amz-id-2: 3cWYOTCteWNkKBCEIBEbpcurpWGfBxLtjryvJLPXRehvlFtLmYBnrHZXUBRIeJCvq5JIWB426RU=
x-amz-request-id: 1M1MTG89K6RHK1WY
last-modified: Fri, 29 Jul 2022 17:30:34 GMT
etag: "e0dd970322929ac74241b3103702fa79"
x-amz-version-id: 9CWmiEfF.tX6_s0dsHiWz0QowawXcyYi
content-type: image/png
server: AmazonS3
accept-ranges: bytes
date: Thu, 24 Nov 2022 17:05:50 GMT
via: 1.1 varnish
age: 329
x-served-by: cache-bos4643-BOS
x-cache: HIT
x-cache-hits: 1
x-timer: S1669309550.144080,VS0,VE10
strict-transport-security: max-age=300
content-length: 172387
% curl -I "https://xpro.mit.edu/images/xEksln7ekhLe8RkZ-U9-MrYHOLc=/20/fill-480x275/QCx_Course_2_Card.original.jpg?v=053cda6c271fa04763519c229cd360762c9e1f91"
HTTP/2 200 
server: nginx
content-type: image/jpeg
x-frame-options: DENY
x-content-type-options: nosniff
referrer-policy: same-origin
via: 1.1 vegur, 1.1 varnish, 1.1 varnish
cache-control: max-age=2592000
accept-ranges: bytes
date: Thu, 24 Nov 2022 17:06:37 GMT
age: 2013354
x-served-by: cache-iad-kcgs7200093-IAD, cache-bos4667-BOS
x-cache: HIT, HIT
x-cache-hits: 1, 1
x-timer: S1669309598.507335,VS0,VE3
vary: Authorization, Cookie
content-length: 49050

acceptance criteria

asadali145 commented 1 year ago

In MITxPro, we are using Wagtail renditions and ServeView does not add such a header. In MITxOnline, we are statically serving the images and Django's serve view adds a Last-Modified header.

asadali145 commented 1 year ago

The image caching issue is solved for now. These extra headers were added by Django in MITxOnline. We can close this one.