diff --git a/docker-compose.local.yml b/docker-compose.local.yml new file mode 100644 index 0000000..b494a2f --- /dev/null +++ b/docker-compose.local.yml @@ -0,0 +1,50 @@ +services: + postgres: + image: postgres:15-alpine + container_name: quixotic-postgres + restart: unless-stopped + environment: + POSTGRES_DB: quixotic + POSTGRES_USER: quixotic + POSTGRES_PASSWORD: quixotic123 + volumes: + - postgres-data:/var/lib/postgresql/data + - ./database/init:/docker-entrypoint-initdb.d + networks: + - quixotic + healthcheck: + test: ["CMD-SHELL", "pg_isready -U quixotic"] + interval: 5s + timeout: 5s + retries: 5 + + quixotic-app: + build: + context: . + dockerfile: Dockerfile + container_name: quixotic-app + restart: unless-stopped + environment: + NODE_ENV: production + PORT: 3000 + DATABASE_URL: postgresql://quixotic:quixotic123@postgres:5432/quixotic + DATABASE_SSL: false + TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN:-} + WEB_APP_URL: http://localhost:3000 + volumes: + - downloads:/app/downloads + ports: + - "3000:3000" + depends_on: + postgres: + condition: service_healthy + networks: + - quixotic + +volumes: + downloads: + postgres-data: + +networks: + quixotic: + driver: bridge diff --git a/public/index.html b/public/index.html index 22e9193..06af595 100644 --- a/public/index.html +++ b/public/index.html @@ -60,11 +60,12 @@ - - + + + @@ -106,6 +107,6 @@ - + diff --git a/src/server.ts b/src/server.ts index cb6db67..63b7c33 100644 --- a/src/server.ts +++ b/src/server.ts @@ -43,21 +43,21 @@ app.use((req: Request, res: Response, next) => { // Optimized caching strategy app.use(express.static('public', { - maxAge: '1d', // Cache static assets for 1 day + maxAge: '365d', // Cache static assets for 1 year by default etag: true, lastModified: true, setHeaders: (res: Response, filePath: string) => { - // Cache images, fonts, etc. longer - if (filePath.match(/\.(jpg|jpeg|png|gif|ico|woff|woff2|ttf|eot)$/)) { + // Cache images, fonts, etc. with immutable flag + if (filePath.match(/\.(jpg|jpeg|png|gif|ico|woff|woff2|ttf|eot|svg)$/)) { res.set('Cache-Control', 'public, max-age=31536000, immutable'); } - // Cache CSS and JS with version string + // Cache CSS and JS with version string for 1 year else if (filePath.match(/\.(css|js)$/)) { - res.set('Cache-Control', 'public, max-age=86400'); // 1 day + res.set('Cache-Control', 'public, max-age=31536000, immutable'); // 1 year } - // HTML files - short cache + // HTML files - short cache with revalidation else if (filePath.match(/\.html$/)) { - res.set('Cache-Control', 'public, max-age=3600'); // 1 hour + res.set('Cache-Control', 'public, max-age=0, must-revalidate'); } } }));