version fix
This commit is contained in:
@@ -65,8 +65,8 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- Load full CSS asynchronously with fallback -->
|
<!-- Load full CSS asynchronously with fallback -->
|
||||||
<link rel="stylesheet" href="style.css?v=3" media="print" onload="this.media='all';this.onload=null">
|
<link rel="stylesheet" href="style.css?v=VERSION" media="print" onload="this.media='all';this.onload=null">
|
||||||
<noscript><link rel="stylesheet" href="style.css?v=3"></noscript>
|
<noscript><link rel="stylesheet" href="style.css?v=VERSION"></noscript>
|
||||||
|
|
||||||
<!-- Load Telegram script asynchronously (defer) -->
|
<!-- Load Telegram script asynchronously (defer) -->
|
||||||
<script src="https://telegram.org/js/telegram-web-app.js" defer></script>
|
<script src="https://telegram.org/js/telegram-web-app.js" defer></script>
|
||||||
@@ -203,6 +203,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Load app script with defer for better performance -->
|
<!-- Load app script with defer for better performance -->
|
||||||
<script src="dist/script.js?v=3" defer></script>
|
<script src="dist/script.js?v=VERSION" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ app.use((req: Request, res: Response, next) => {
|
|||||||
|
|
||||||
// Optimized caching strategy
|
// Optimized caching strategy
|
||||||
app.use(express.static('public', {
|
app.use(express.static('public', {
|
||||||
maxAge: '365d', // Cache static assets for 1 year by default
|
maxAge: 0, // Don't cache by default, set specific headers below
|
||||||
etag: true,
|
etag: true,
|
||||||
lastModified: true,
|
lastModified: true,
|
||||||
setHeaders: (res: Response, filePath: string) => {
|
setHeaders: (res: Response, filePath: string) => {
|
||||||
@@ -52,13 +52,21 @@ app.use(express.static('public', {
|
|||||||
if (filePath.match(/\.(jpg|jpeg|png|gif|ico|woff|woff2|ttf|eot|svg)$/)) {
|
if (filePath.match(/\.(jpg|jpeg|png|gif|ico|woff|woff2|ttf|eot|svg)$/)) {
|
||||||
res.set('Cache-Control', 'public, max-age=31536000, immutable');
|
res.set('Cache-Control', 'public, max-age=31536000, immutable');
|
||||||
}
|
}
|
||||||
// Cache CSS and JS with version string for 1 year
|
// Cache CSS and JS with version string for 1 year (they have ?v= in URL)
|
||||||
else if (filePath.match(/\.(css|js)$/)) {
|
else if (filePath.match(/\.(css|js)$/)) {
|
||||||
res.set('Cache-Control', 'public, max-age=31536000, immutable'); // 1 year
|
res.set('Cache-Control', 'public, max-age=31536000, immutable');
|
||||||
}
|
}
|
||||||
// HTML files - short cache with revalidation
|
// HTML files - NO CACHE
|
||||||
else if (filePath.match(/\.html$/)) {
|
else if (filePath.match(/\.html$/)) {
|
||||||
res.set('Cache-Control', 'public, max-age=0, must-revalidate');
|
res.set('Cache-Control', 'no-cache, no-store, must-revalidate');
|
||||||
|
res.set('Pragma', 'no-cache');
|
||||||
|
res.set('Expires', '0');
|
||||||
|
}
|
||||||
|
// JSON files (version.json) - NO CACHE
|
||||||
|
else if (filePath.match(/\.json$/)) {
|
||||||
|
res.set('Cache-Control', 'no-cache, no-store, must-revalidate');
|
||||||
|
res.set('Pragma', 'no-cache');
|
||||||
|
res.set('Expires', '0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
@@ -99,8 +107,8 @@ app.get('/', (req: Request, res: Response) => {
|
|||||||
// Read HTML and inject version
|
// Read HTML and inject version
|
||||||
try {
|
try {
|
||||||
let html = fs.readFileSync(indexPath, 'utf8');
|
let html = fs.readFileSync(indexPath, 'utf8');
|
||||||
// Replace version placeholders with actual version
|
// Replace all version placeholders with actual version
|
||||||
html = html.replace(/\?v=\d+/g, `?v=${appVersion}`);
|
html = html.replace(/\?v=(VERSION|\d+)/g, `?v=${appVersion}`);
|
||||||
res.send(html);
|
res.send(html);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Error serving HTML:', error);
|
logger.error('Error serving HTML:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user