@@ -6,6 +6,7 @@ import 'package:path/path.dart' as p;
66
77import 'package:pub_dev/dartdoc/dartdoc_page.dart' ;
88import 'package:pub_dev/dartdoc/models.dart' ;
9+ import 'package:pub_dev/frontend/handlers/cache_control.dart' ;
910import 'package:pub_dev/shared/exceptions.dart' ;
1011import 'package:pub_dev/shared/handlers.dart' ;
1112import 'package:pub_dev/shared/redis_cache.dart' ;
@@ -90,7 +91,10 @@ Future<shelf.Response> handleDartDoc(
9091 );
9192 final htmlBytes = await htmlBytesCacheEntry.get ();
9293 if (htmlBytes != null ) {
93- return htmlBytesResponse (htmlBytes);
94+ return htmlBytesResponse (
95+ htmlBytes,
96+ headers: CacheControl .packageContentPage.headers,
97+ );
9498 }
9599
96100 // check cached status for redirect or missing pages
@@ -211,7 +215,10 @@ Future<shelf.Response> handleDartDoc(
211215 switch (status.code) {
212216 case DocPageStatusCode .ok:
213217 await htmlBytesCacheEntry.set (bytes! );
214- return htmlBytesResponse (bytes);
218+ return htmlBytesResponse (
219+ bytes,
220+ headers: CacheControl .packageContentPage.headers,
221+ );
215222 case DocPageStatusCode .redirect:
216223 return redirectPathResponse (status.redirectPath! );
217224 case DocPageStatusCode .missing:
@@ -236,13 +243,14 @@ Future<shelf.Response> handleDartDoc(
236243 }
237244
238245 if (request.method.toUpperCase () == 'HEAD' ) {
239- return htmlResponse ('' );
246+ return htmlResponse ('' , headers : CacheControl .packageContentPage.headers );
240247 }
241248
242249 final acceptsGzip = request.acceptsGzipEncoding ();
243250 return shelf.Response .ok (
244251 acceptsGzip ? dataGz : gzip.decode (dataGz),
245252 headers: {
253+ ...CacheControl .packageContentPage.headers,
246254 'Content-Type' : mime,
247255 'Vary' : 'Accept-Encoding' , // body depends on accept-encoding!
248256 if (acceptsGzip) 'Content-Encoding' : 'gzip' ,
0 commit comments