strapi-community / strapi-plugin-local-image-sharp

Dynamically resize, format and optimize images based on url modifiers.
https://strapi-community.github.io/strapi-plugin-local-image-sharp/
65 stars 17 forks source link

[Performance] Cache-Control in HTTP response header #19

Closed candidosales closed 11 months ago

candidosales commented 1 year ago

I'm using the format URL, and I noticed that the HTTP response headers aren't sending the Cache-Control attribute.

Using the strapi-plugin-local-image-sharp:

CleanShot 2023-02-27 at 17 02 58@2x

Without strapi-plugin-local-image-sharp:

CleanShot 2023-02-27 at 17 03 26@2x

Could you add a new attribute to set the maxAge of the Cache-Control in the response headers? Example: https://docs-v3.strapi.io/developer-docs/latest/development/plugins/upload.html#using-a-provider

config/plugin.js

module.exports = ({ env })=>({
  "local-image-sharp": {
    config: {
      cacheDir: ".image-cache",
      maxAge: 86400000,
    },
  }
});

It's precious for performance and metrics.

CleanShot 2023-02-27 at 17 06 30@2x