From 4d4dbba0101fd6e2efb7b9f269f0c0d2fe1ef384 Mon Sep 17 00:00:00 2001 From: Matt Hills Date: Mon, 20 Oct 2025 22:56:07 -0400 Subject: [PATCH] Fix image update issue by adding cache-busting timestamps Add timestamp query parameters to image URLs to prevent browser caching from showing stale images after updates. Images now display immediately after being updated. --- src/app/blueprints/admin/routes.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/blueprints/admin/routes.py b/src/app/blueprints/admin/routes.py index f18a63d..d9058a4 100644 --- a/src/app/blueprints/admin/routes.py +++ b/src/app/blueprints/admin/routes.py @@ -3,6 +3,7 @@ from . import admin_bp from app.models import TenantModel, ProductModel, ARFieldModel, UserModel from app.services import ProductService from app.decorators.auth import tenant_access_required +import time @admin_bp.route('/add', methods=['GET', 'POST']) @tenant_access_required @@ -78,7 +79,9 @@ def add_product(tenant_id): }) field_suffix = field_name[1:] if field_name.startswith('_') else field_name - image_path = f"/images/{product_id}_{field_suffix}.{extension}" + # Add timestamp for cache busting + timestamp = int(time.time()) + image_path = f"/images/{product_id}_{field_suffix}.{extension}?v={timestamp}" if field_name == '_image': image_data = img_data @@ -217,7 +220,9 @@ def edit_product(tenant_id, product_id): }) field_suffix = field_name[1:] if field_name.startswith('_') else field_name - existing_field["value"] = f"/images/{product_id}_{field_suffix}.{extension}" + # Add timestamp for cache busting + timestamp = int(time.time()) + existing_field["value"] = f"/images/{product_id}_{field_suffix}.{extension}?v={timestamp}" if field_name == '_image': image_data = img_data