image caching optimized

This commit is contained in:
2026-06-12 15:06:55 -05:00
parent 84c24b2e92
commit 577b63b7e7
3 changed files with 8 additions and 3 deletions

View File

@@ -16,6 +16,11 @@ async function bootstrap() {
//app.use('/bizmatch/payment/webhook', bodyParser.raw({ type: 'application/json' })); //app.use('/bizmatch/payment/webhook', bodyParser.raw({ type: 'application/json' }));
// Serve static files from pictures directory // Serve static files from pictures directory
app.use('/pictures', express.static(PICTURES_DIR)); app.use('/pictures', express.static(PICTURES_DIR));
// Prevent browsers from caching 404s on /pictures/*
app.use('/pictures', (_req, res) => {
res.set('Cache-Control', 'no-store');
res.status(404).end();
});
app.setGlobalPrefix('bizmatch'); app.setGlobalPrefix('bizmatch');

View File

@@ -161,7 +161,7 @@ export class DetailsCommercialPropertyListingComponent extends BaseDetailsCompon
} }
if (this.listing.imageOrder && Array.isArray(this.listing.imageOrder)) { if (this.listing.imageOrder && Array.isArray(this.listing.imageOrder)) {
this.listing.imageOrder.forEach(image => { this.listing.imageOrder.forEach(image => {
const imageURL = `${this.env.imageBaseUrl}/pictures/property/${this.listing.imagePath}/${this.listing.serialId}/${image}`; const imageURL = `${this.env.imageBaseUrl}/pictures/property/${this.listing.imagePath}/${this.listing.serialId}/${image}?_ts=${new Date(this.listing.updated).getTime()}`;
this.images.push(new ImageItem({ src: imageURL, thumb: imageURL })); this.images.push(new ImageItem({ src: imageURL, thumb: imageURL }));
}); });
} }
@@ -185,7 +185,7 @@ export class DetailsCommercialPropertyListingComponent extends BaseDetailsCompon
yearBuilt: (this.listing as any).yearBuilt, yearBuilt: (this.listing as any).yearBuilt,
images: this.listing.imageOrder?.length > 0 images: this.listing.imageOrder?.length > 0
? this.listing.imageOrder.map(img => ? this.listing.imageOrder.map(img =>
`${this.env.imageBaseUrl}/pictures/property/${this.listing.imagePath}/${this.listing.serialId}/${img}`) `${this.env.imageBaseUrl}/pictures/property/${this.listing.imagePath}/${this.listing.serialId}/${img}?_ts=${new Date(this.listing.updated).getTime()}`)
: [] : []
}; };
this.seoService.updateCommercialPropertyMeta(propertyData); this.seoService.updateCommercialPropertyMeta(propertyData);

View File

@@ -44,7 +44,7 @@
</button> </button>
</div> </div>
@if (listing.imageOrder?.length>0){ @if (listing.imageOrder?.length>0){
<img [appLazyLoad]="env.imageBaseUrl + '/pictures/property/' + listing.imagePath + '/' + listing.serialId + '/' + listing.imageOrder[0]" <img [appLazyLoad]="env.imageBaseUrl + '/pictures/property/' + listing.imagePath + '/' + listing.serialId + '/' + listing.imageOrder[0] + '?_ts=' + listing.updated"
[alt]="altText.generatePropertyListingAlt(listing)" [alt]="altText.generatePropertyListingAlt(listing)"
class="w-full h-48 object-cover" class="w-full h-48 object-cover"
width="400" width="400"