简体   繁体   English

如何减少Web应用程序中资产的大小

[英]How to reduce the size of assets in web application

In my app(tourism), We have used lot of images(png and gif) and now we need to reduce the assets size(image/gif/png). 在我的应用程序(旅游)中,我们使用了很多图像(png和gif),现在我们需要减小资产大小(image / gif / png)。

  1. Already tried the base64 convertion as a json. 已经尝试将base64转换作为json。 As this blog stated base64 encoded image size while converting an image into base64, it will create a larger file. 正如此博客指出将图像转换为base64时将base64编码的图像大小一样 ,它将创建一个更大的文件。
  2. Second options is store images in DB and load them (I think, this is not suitable in my case) 第二种选择是将图像存储在数据库中并加载它们(我认为这不适合我的情况)

Is there's an alternative way to reduce the assets size, Thanks in advance. 有没有其他减小资产规模的方法,请提前谢谢。

Image size could be reduced in multiple ways (trading image quality). 图像大小可以通过多种方式减少(交易图像质量)。 It might solve your problem now but it will never scale with a number of images/assets. 它现在可能会解决您的问题,但是它永远不会随着许多图像/资产缩放。

Assets storage 资产储存

Any cloud provider has a product for storing assets, where AWS's S3 storage is most recognized. 任何云提供商都拥有一种用于存储资产的产品,其中最受人们认可的是AWS的S3存储。 This storage type is ideal for your case, it's fast, reliable and cheap. 这种存储类型非常适合您的情况,它快速,可靠且便宜。 A custom solution could be used if using the services of a cloud provider is not an option. 如果不能选择使用云提供商的服务,则可以使用自定义解决方案。

Caching static files 缓存静态文件

Static assets as images are the ideal candidates for caching. 静态资产作为图像是缓存的理想选择。 They are called Content Delivery Network (CDN) and there are dozens of providers who offer such product. 它们被称为内容交付网络(CDN),有数十家提供此类产品的提供商。 Make sure your application uses E-tags 确保您的应用程序使用电子标签

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM