WordPress / performance

Performance plugin from the WordPress Performance Group, which is a collection of standalone performance modules.
https://wordpress.org/plugins/performance-lab/
GNU General Public License v2.0
352 stars 94 forks source link

Site Health: detect web server AVIF mime type support #1263

Open adamsilverstein opened 3 months ago

adamsilverstein commented 3 months ago

Feature Description

When the server supports AVIF processing, add detection in site health to check if AVIF images are being served with the avif type or with octet-stream. Warn users when avif isn't being used. Consider attempting to apply fix via .htaccess?

Details

Since launching AVIF support in WordPress 6.5, some users are discovering that their AVIF images are being served with the network type "octet-stream". The impact is relatively low since browsers know to serve these .avif files as AVIF images, however it is worth trying to detect and fix if possible.

Examples

The website https://ground-cd.com/blog/avif/ uses AVIF images, checking the network panel the type shows as "octet-stream" instead of "avif". image

On the other hand, this site serves up AVIF images correctly, with the avif type: https://aomedia.org/blog%20posts/avif-meet-the-next-level-image-file-format/ image

Underlying issue

This issue can happen if the web server does not include the image/avif MIME types in its configuration. For Apache, the host may have a custom config, and configurations could (possibly) be added via .htaccess

Nginx added AVIF to their base config in 2021 (PR).

Apache config would probably be host or distribution dependent, so these might need updating. For Apache, I opened this PR to add it to their config. Users can ask their hosts to add the configuration and this is a very low risk change for hosts.

Suggested fix

westonruter commented 3 months ago

I see this is labelled for the Modern Image Formats plugin, however all of the Site Health tests have been located in the Performance Lab plugin. I think it makes sense to move Site Health tests which are closely related to certain plugins to actually move them to those plugins.

adamsilverstein commented 3 months ago

I think it makes sense to move Site Health tests which are closely related to certain plugins to actually move them to those plugins.

+1 - Good point, I think we discussed that already.