#!/bin/bash # Simple cache busting script - adds git hash to static asset URLs set -e # Get current git commit hash (short version) if git rev-parse --short HEAD >/dev/null 2>&1; then VERSION=$(git rev-parse --short HEAD) else # Fallback to timestamp if not in git repo VERSION=$(date +%s) fi echo "Adding cache-busting version: $VERSION" # Update index.html if [ -f "public/index.html" ]; then echo "Updating public/index.html..." # Replace .css with .css?v=VERSION sed -i.bak "s/\.css\"/\.css?v=$VERSION\"/g" public/index.html # Replace .js with .js?v=VERSION sed -i.bak "s/\.js\"/\.js?v=$VERSION\"/g" public/index.html rm public/index.html.bak fi # Update hardware.html if [ -f "public/hardware.html" ]; then echo "Updating public/hardware.html..." sed -i.bak "s/\.css\"/\.css?v=$VERSION\"/g" public/hardware.html sed -i.bak "s/\.js\"/\.js?v=$VERSION\"/g" public/hardware.html rm public/hardware.html.bak fi echo "✓ Cache-busting version $VERSION applied" echo "" echo "Modified URLs now include ?v=$VERSION" echo "Deploy these files to force clients to fetch fresh copies"