Skip to content

Commit

Permalink
Merge branch 'disable-cache' into release-v0.5.18
Browse files Browse the repository at this point in the history
  • Loading branch information
tombeynon committed Aug 19, 2024
2 parents 85be37d + 9335bfe commit 1ef2e0b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions proxy/proxyController.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { debugLog } from '../utils.js';

const { createProxyServer } = httpProxy;

const CACHED_REQUESTS = [
const cacheEnabled = process.env.DISABLE_CACHE != '1'

const CACHED_REQUESTS = [
{
path: 'cosmos/staking/v1beta1/validators$',
maxAge: 60
Expand Down Expand Up @@ -107,7 +109,7 @@ const ProxyController = (client, registry) => {
let { path } = ctx.request;
path = path.split('/').slice(2).join('/')
const match = CACHED_REQUESTS.find(el => path.match(el.path))
if(match){
if(cacheEnabled && match){
if (await ctx.cashed(match.maxAge)){
debugLog('Using cache', path)
return
Expand Down Expand Up @@ -168,11 +170,11 @@ const ProxyController = (client, registry) => {
const regexp = new RegExp("\^\\/" + chainName, 'g');
ctx.req.url = ctx.req.url.replace(regexp, '')

ctx.res.on('close', () => {
ctx.res.on('close', () => {
resolve()
})

ctx.res.on('finish', () => {
ctx.res.on('finish', () => {
resolve()
})

Expand All @@ -192,4 +194,4 @@ const ProxyController = (client, registry) => {
}
}

export default ProxyController;
export default ProxyController;

0 comments on commit 1ef2e0b

Please sign in to comment.