implement content-hash based image cache invalidation
Add content-based hashing to recipe images for proper cache invalidation while maintaining graceful degradation through dual file storage. Changes: - Add imageHash utility with SHA-256 content hashing (8-char) - Update Recipe model to store hashed filenames in images[0].mediapath - Modify image upload endpoint to save both hashed and unhashed versions - Update frontend components to use images[0].mediapath with fallback - Add migration endpoint to hash existing images (production-only) - Update image delete/rename endpoints to handle both file versions Images are now stored as: - recipe.a1b2c3d4.webp (hashed, cached forever) - recipe.webp (unhashed, graceful degradation fallback) Database stores hashed filename for cache busting, while unhashed version remains on disk for backward compatibility and manual uploads.
This commit is contained in:
@@ -42,7 +42,7 @@ export function generateRecipeJsonLd(data: any) {
|
||||
"keywords": data.tags?.join(', '),
|
||||
"image": {
|
||||
"@type": "ImageObject",
|
||||
"url": `https://bocken.org/static/rezepte/full/${data.short_name}.webp`,
|
||||
"url": `https://bocken.org/static/rezepte/full/${data.images?.[0]?.mediapath || `${data.short_name}.webp`}`,
|
||||
"width": 1200,
|
||||
"height": 800
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user