Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

caching images #287

Open
vdias38 opened this issue Feb 18, 2019 · 3 comments
Open

caching images #287

vdias38 opened this issue Feb 18, 2019 · 3 comments
Labels
images perf A code change that improves performance

Comments

@vdias38
Copy link
Contributor

vdias38 commented Feb 18, 2019

@vdias38 vdias38 added images perf A code change that improves performance labels Feb 18, 2019
@vdias38
Copy link
Contributor Author

vdias38 commented Feb 26, 2019

imgcache.js is not well supported and not seems to be a future-proof way.

  • PWA: use service workers
  • Native: ionic-image-loader

@vdias38
Copy link
Contributor Author

vdias38 commented Mar 7, 2019

$ npm install --save ionic-image-loader

Import IonicImageLoader on home module

On /pages/home/home.html replace

<img src="./assets/images/header-clean.png" class="logo" alt="infomobi">

By <img-loader [src]="settings.logoUrl" fallbackUrl="./assets/images/header-clean.png" fallbackAsPlaceholder="true" useImg [imgAttributes]="imageAttributes"></img-loader>
OR set by default settings.logoUrl = "./assets/images/header-clean.png"
Where

  1. Include the ImageAttribute model in your .ts
    import { ImageAttribute } from 'ionic-image-loader'
  2. Generate an array of ImageAttribute objects
const imageAttributes: ImageAttribute[] = [];
imageAttributes.push({
  element: 'class',
  value: 'logo'
})

@vdias38
Copy link
Contributor Author

vdias38 commented Mar 12, 2019

to allow PWA caching we should define an url pattern

How to cache images using service worker

By default any images under ./assets are cached by angular sw

Should add a new AssetGroup to cache uploads img from meumobi

, {
    "name": "uploads",
    "installMode": "lazy",
    "updateMode": "lazy",
    "resources": {
      "urls": [
        "/uploads/**"
      ]
    },
  "cacheConfig": {
        "maxSize": 250,
        "maxAge": "7d"
      }

@vdias38 vdias38 added this to the Save uuid and bugs fixing milestone Jul 8, 2019
@vdias38 vdias38 removed this from the Save uuid and bugs fixing milestone Aug 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
images perf A code change that improves performance
Projects
None yet
Development

No branches or pull requests

1 participant