@@ -6,12 +6,12 @@ import (
6
6
"encoding/base64"
7
7
"errors"
8
8
"fmt"
9
- "github.com/lightningnetwork/lnd/lncfg"
10
9
"io/ioutil"
11
10
"net"
12
11
"net/http"
13
12
"os"
14
13
"path/filepath"
14
+ "regexp"
15
15
"strings"
16
16
"sync"
17
17
"time"
@@ -24,6 +24,7 @@ import (
24
24
"github.com/lightninglabs/loop/loopd"
25
25
"github.com/lightninglabs/loop/looprpc"
26
26
"github.com/lightningnetwork/lnd"
27
+ "github.com/lightningnetwork/lnd/lncfg"
27
28
"github.com/lightningnetwork/lnd/lnrpc"
28
29
"github.com/lightningnetwork/lnd/lntest/wait"
29
30
"github.com/lightningnetwork/lnd/macaroons"
@@ -460,7 +461,16 @@ func (g *Shushtar) startGrpcWebProxy() error {
460
461
// something we don't know in which case the static file server
461
462
// will answer with a 404.
462
463
log .Infof ("Handling static file request: %s" , req .URL .Path )
463
- staticFileServer .ServeHTTP (resp , req )
464
+ // add 1-year cache header for static files. React uses content-based
465
+ // hashes in file names, so when any file is updated, the url will
466
+ // change causing the browser cached version to be invalidated
467
+ var re = regexp .MustCompile (`^\/(static|fonts|icons)\/.*` )
468
+ if re .MatchString (req .URL .Path ) {
469
+ resp .Header ().Set ("Cache-Control" , "max-age=31536000" )
470
+ }
471
+ // transfer static files using gzip to save up to 70% of bandwidth
472
+ gzipHandler := makeGzipHandler (staticFileServer .ServeHTTP )
473
+ gzipHandler (resp , req )
464
474
}
465
475
466
476
// Create and start our HTTPS server now that will handle both gRPC web
0 commit comments