diff --git a/nginx/default.conf b/nginx/default.conf index e0d455a..e38b330 100644 --- a/nginx/default.conf +++ b/nginx/default.conf @@ -7,7 +7,7 @@ server { proxy_cache request_cache; proxy_cache_valid 200 60m; proxy_cache_valid 404 10m; - proxy_cache_key $uri; + proxy_cache_key $host$uri; proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; add_header X-Cache $upstream_cache_status; @@ -16,8 +16,8 @@ server { expires 30d; add_header Cache-Control "public, no-transform"; - proxy_pass http://nsite; proxy_set_header Host $host; + proxy_pass http://nsite; } # Manual cache invalidation ( cant use proxy_cache_purge ) diff --git a/src/index.ts b/src/index.ts index 7bae3d7..8381fa1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -50,12 +50,19 @@ app.use(async (ctx, next) => { const pubkey = (ctx.state.pubkey = await resolveNpubFromHostname(ctx.hostname)); if (pubkey) { - console.log(`${pubkey}: Fetching relays`); - let relays = await userRelays.get(pubkey); if (!relays) { + console.log(`${pubkey}: Fetching relays`); + relays = await getUserOutboxes(pubkey); - if (relays) await userRelays.set(pubkey, relays); + if (relays) { + await userRelays.set(pubkey, relays); + console.log(`${pubkey}: Found ${relays.length} relays`); + } else { + relays = []; + await userServers.set(pubkey, [], 30_000); + console.log(`${pubkey}: Failed to find relays`); + } } console.log(`${pubkey}: Searching for ${ctx.path}`);