Skip to content

Commit

Permalink
Cache
Browse files Browse the repository at this point in the history
  • Loading branch information
carlssonk committed Sep 17, 2024
1 parent 6536205 commit 0e7636b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
15 changes: 12 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ const app = express();
const server = require("http").createServer(app);
const PORT = process.env.PORT || 8080;
const WebSocket = require("ws")
const WEB_URL = process.env.NODE_ENV === "production" ? "https://blackjack.carlssonk.com/" : `http://localhost:${PORT}/`;
const WEB_URL = process.env.NODE_ENV === "production" ? `https://${process.env.DOMAIN_NAME}/` : `http://localhost:${PORT}/`;

const wss = new WebSocket.Server({ server:server })


const cacheDuration = 1000 * 60 * 60 * 24 * 365; // 1 year

// Serve all the static files, (ex. index.html app.js style.css)
app.use(express.static("public/"));
// Before 8081
app.use(express.static("public/"), {
maxAge: cacheDuration,
setHeaders: (res) => {
// Set caching headers
res.setHeader('Cache-Control', `public, max-age=${cacheDuration}`);
res.setHeader('Expires', new Date(Date.now() + cacheDuration * 1000).toUTCString());
}
});

server.listen(PORT, () =>
console.log(`Listening on ${process.env.PORT} or 8080`)
);
Expand Down
2 changes: 1 addition & 1 deletion public/credits.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/css/dist/style.css">
<link rel="stylesheet" href="/css/style.scss">
<title>blackjack.io</title>
<title>blackjack21</title>
</head>
<body>
<div id="credits-container">
Expand Down
8 changes: 3 additions & 5 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
<meta name="keywords" content="blackjack, io, casino, online, multiplayer, friends, game, card game, 21">
<meta property="og:title" content="PLAY BLACKJACK WITH YOUR FRIENDS">
<meta property="og:type" content="website">
<meta property="og:url" content="http://blackjack21.io">
<meta property="og:image" itemprop="image" content="https://i.ibb.co/fHkyMJS/blackjack21-showcase.jpg">
<title>Blackjack21.io</title>
<title>Blackjack21</title>
<link rel="stylesheet" href="/css/dist/style.css">
<link rel="stylesheet" href="/css/style.scss">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css">
Expand Down Expand Up @@ -88,8 +87,7 @@ <h1>PAYOUT</h1>
</div>

<div id="main-menu" class="">
<h1 id="blackjack-title">blackjack21<span>.io</span></h1>
<!-- <img id="blackjack-title" src="/imgs/blackjack21io.png" alt="blackjack21.io"> -->
<h1 id="blackjack-title">blackjack21</h1>
<div id="main-box">
<div id="avatar-box">
<button class="prev" onclick="plusSlides(-1)">
Expand Down Expand Up @@ -147,7 +145,7 @@ <h1 id="blackjack-title">blackjack21<span>.io</span></h1>
</div>

<div id="about-box">
<strong>blackjack21.io</strong> is a free multiplayer casino game. It's an online version of the traditional blackjack played at real casinos, with some exceptions.
<strong>blackjack21</strong> is a free multiplayer casino game. It's an online version of the traditional blackjack played at real casinos, with some exceptions.
<ul>
<li>Every game uses 1 standard 52-card pack that shuffles every round.</li>
<li>Current version of the game does not support Splitting Cards & Insurance.</li>
Expand Down

0 comments on commit 0e7636b

Please sign in to comment.