Versions: node : 10.7.0 npm : 6.1.0
The Architecture: My page is a simple concept, it renders new photos that are placed in the assets folder, the information is added to a json file which is placed within the assets folder. I have a service that reads the json file then sends an Observable to the component which has the location of the image and some other fields.
The Problem When I publish the site, all browsers render the contents from last publish and do not display the updated pictures or json file.
When I run local, I have no problem, all photos display.
Can someone please help shed a little light, thanks.
Here is what the code looks like:
JSON
[
{
"id": "",
"name": "pic1",
"location": "../../assets/photos/pic1.jpg",
"date": "4/28/2018",
"comments": "this is pic1"
},
{
"id": "",
"name": "pic2",
"location": "../../assets/photos/pic2.jpg",
"date": "4/28/2018",
"comments": "this is pic2"
}
]
The Service
getAllPhotos(){
photoPath = '../../assets/photoInfo.json';
return this.http.get(this.photoPath);
}
The Component
data : any;
constructor(private _data: PhotoAlbumService,private zone : NgZone, public cd: ChangeDetectorRef) {
this.data = new Array<IPhoto>();
}
getRecentPhotos(): void {
this._data.getAllPhotos()
.subscribe(recent => {
this.zone.run(() => { // <== added
this.data = recent;
});
});
}
ngOnInit() {
let timer;
this.getRecentPhotos();
timer = timer(2000, 5000);
timer.subscribe(() => this.getRecentPhotos());
}