我有一个带有全屏背景图像的离子应用程序,当我使用不同的参数导航到同一条路线时,背景图像会闪烁。
出于测试目的,我使用了 pixabay 图像的 url,根本没有闪烁效果,现在我使用本地(在应用程序中)存储的图像,它会闪烁。(图像很小,大约 200kb)所以我假设存在某种缓存问题?
背景图片的实现:
<ion-content
[ngStyle]="{'background-image': 'url(' + sceneBackground + ')'}"
class="backgound-image ion-no-padding"
routerDirection="root">
链接
<a class="fullLink"
[routerLink]="['/page', bId, cId, nId"
routerDirection="root"
*ngIf="content[currentPos].type !== 'index'">
来自 URL 的图像是在没有请求的情况下加载的,对于本地图像总是有请求,如何在 ionic 中缓存本地文件以防止请求?
网址请求:
Summary
URL: https://cdn.pixabay.com/photo/2016/08/11/23/55/redwood-national-park-1587301_1280.jpg
Status: 200 OK
Source: Disk Cache
Initiator:
platform-browser.js:2817
Request
No request, served from the disk cache.
本地请求:
Summary
URL: http://localhost:4200/assets/scenes/scene-office.jpg
Status: 304 Not Modified
Source: Memory Cache
Address: 127.0.0.1:4200
Initiator:
platform-browser.js:2817
Request
GET /assets/scenes/scene-office.jpg HTTP/1.1
Accept: image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5
Accept-Encoding: gzip, deflate
If-None-Match: W/"48bd6-1wY/xftZTec7f4u3zn/RZL/oTKg"
Host: localhost:4200
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Safari/605.1.15
Accept-Language: en-us
Referer: http://localhost:4200/red/1/77
Connection: keep-alive