hint
hint copied to clipboard
Chore: add more media mimetypes
Add some mimetypes for images/audio/video.
Pull request checklist
Make sure you:
- [x] Signed the Contributor License Agreement
- [x] Followed the commit message guidelines
Short description of the change(s)
Add some mimetypes for long-lived resources to the http-cache
hint.
Also worth noting that some of these mimetypes aren't supported in all browsers; adding a check to the compat hint to ensure that these are used in backward-compatible ways (e.g. in a <picture>
element with fallbacks) might be useful.
Question for @webhintio/contributors, is there any audio/image/video that shouldn't have a long cache? because one solution could be to have something like video/*
image/*
audio/*
.
On Mon, Dec 14, 2020 at 09:17:45AM -0800, Jesus David GarcÃa Gomez wrote:
is there any audio/image/video that shouldn't have a long cache?
because one solution could be to have something likevideo/*
image/*
audio/*
.
Good point; I can update + force-push to do this for all audio, video, image, and font subtypes.
-- /Seirdy
I like the idea of not maintaining a granular list here since we don't need to vary behavior on specific audio/font/image/video types. Seems if there are any exceptions it'd be a shorter list to maintain that rather than listing everything to begin with.
On Thu, Dec 17, 2020 at 09:34:45AM -0800, Tony Ross wrote:
I like the idea of not maintaining a granular list here since we don't need to vary behavior on specific audio/image/video types. Seems if there are any exceptions it'd be a shorter list to maintain that rather than listing everything to begin with.
Looks like that'll be a bit more than just replacing the subtype with an asterisk. I switched back to enumerating individual subtypes until then, and I'll take a closer look this weekend.
Should be mergeable now. I've attached a patch to switch back if anyone wants it.
-- /Seirdy
From 0336c5cb9d019edcfddb322d8117fcaf6e059944 Mon Sep 17 00:00:00 2001 From: Rohan Kumar [email protected] Date: Fri, 18 Dec 2020 17:34:59 -0800 Subject: [PATCH] Fix: Name specific mime subtypes in longCached
Matching all subtypes with "mime/*" causes a failure; enumerate specific ones until tha is handled.
packages/hint-http-cache/src/hint.ts | 41 ++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 8 deletions(-)
diff --git a/packages/hint-http-cache/src/hint.ts b/packages/hint-http-cache/src/hint.ts index 9babf405d..370a999c2 100644 --- a/packages/hint-http-cache/src/hint.ts +++ b/packages/hint-http-cache/src/hint.ts @@ -65,15 +65,40 @@ export default class HttpCacheHint implements IHint { const maxAgeResource = context.hintOptions && context.hintOptions.maxAgeResource || 31536000; // 1 year /** Resources' mediaType that should be cached for a long time.*/ const longCached = [
-
'audio/*',
-
'image/*',
-
'video/*',
-
'font/*',
-
'application/vnd.ms-fontobject',
-
'text/css', 'application/manifest+json',
-
'text/javascript'];
-
'audio/ogg',
-
'audio/opus',
-
'audio/mpeg',
-
'audio/mp4',
-
'audio/x-flac',
-
'audio/x-wav',
-
'font/collection',
-
'application/vnd.ms-fontobject',
-
'font/opentype',
-
'font/otf',
-
'font/ttf',
-
'font/woff',
-
'font/woff2',
-
'image/avif',
-
'image/bmp',
-
'image/gif',
-
'image/jpeg',
-
'image/jp2',
-
'image/png',
-
'image/svg+xml',
-
'image/webp',
-
'image/x-icon',
-
'text/css',
-
'text/javascript',
-
'video/mp4',
-
'video/ogg',
-
'video/webm',
-
'video/x-matroska']; /** The predefined patterns for file revving.*/ const predefinedRevvingPatterns: RegExp[] = [ /*
-- 2.26.2