wp-media / imagify-plugin

Speed up your website with lighter images without losing quality.
https://imagify.io
69 stars 24 forks source link

Apply nginx rules for next gen images #824

Closed wordpressfan closed 3 months ago

wordpressfan commented 3 months ago

Description

Fixes #821

Documentation

User documentation

Here we are playing with rewrite rules so users need to reload their nginx after upload to get those new rules being applied.

Technical documentation

Here I used the webp class to write the next gen handling rewrite rules so we don't need to run any code with plugin update to remove the old rules and insert the new ones, as I think those webp rules were already there in previous versions.

Also I kept avif rewrite rules empty to unify the code structure and keep it as currently used, but it's not added to the config file at all because it's empty.

If you think this would be confusing having the comment Imagify: rewrite rules for webp let me know and I can check how to do this upgrade routine here in imagify.

Type of change

Delete options that are not relevant.

New dependencies

List any new dependencies that are required for this change.

Risks

List possible performance & security issues or risks, and explain how they have been mitigated.

As mentioned above we have two risks:

  1. We need to tell users to restart their nginx once our rules are changed, maybe we can use admin notices or add this to our documentation in a clear way.
  2. We need to check if the comment in config file is confusing or it;s OK to have Imagify: rewrite rules for webp but it's handling webp and avif.

What do u think @piotrbak ?

Checklists

Feature validation

Documentation

Code style

Observability

Risks

Mai-Saad commented 3 months ago

Rules applied correctly on apache, local and imagify.rocketlabs.

Note: on https://imagify.rocketlabsqa.ovh/ if we uploaded the zip file of any plugin, we will have error in media library (may needs further investigations when documenting changes needed at nginx server) => without playing with nginx rules at newer.rocketlabsqs upload plugin zip is fine Screenshot from 2024-03-01 09-21-55