improve efficiency for small static files
This commit is contained in:
parent
30b68945b4
commit
61688a0c6d
@ -238,6 +238,15 @@ func (list SFileList) JSTmplInit() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// Don't use Gzip if we get meagre gains from it as it takes longer to process the responses
|
||||||
|
if len(gzipData) >= (len(data) + 150) {
|
||||||
|
gzipData = nil
|
||||||
|
} else {
|
||||||
|
diff := len(data) - len(gzipData)
|
||||||
|
if diff <= len(data)/100 {
|
||||||
|
gzipData = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get a checksum for CSPs and cache busting
|
// Get a checksum for CSPs and cache busting
|
||||||
hasher := sha256.New()
|
hasher := sha256.New()
|
||||||
@ -279,7 +288,7 @@ func (list SFileList) Init() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Don't use Gzip if we get meagre gains from it as it takes longer to process the responses
|
// Don't use Gzip if we get meagre gains from it as it takes longer to process the responses
|
||||||
if len(gzipData) >= (len(data) + 100) {
|
if len(gzipData) >= (len(data) + 150) {
|
||||||
gzipData = nil
|
gzipData = nil
|
||||||
} else {
|
} else {
|
||||||
diff := len(data) - len(gzipData)
|
diff := len(data) - len(gzipData)
|
||||||
@ -316,6 +325,15 @@ func (list SFileList) Add(path, prefix string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// Don't use Gzip if we get meagre gains from it as it takes longer to process the responses
|
||||||
|
if len(gzipData) >= (len(data) + 150) {
|
||||||
|
gzipData = nil
|
||||||
|
} else {
|
||||||
|
diff := len(data) - len(gzipData)
|
||||||
|
if diff <= len(data)/100 {
|
||||||
|
gzipData = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get a checksum for CSPs and cache busting
|
// Get a checksum for CSPs and cache busting
|
||||||
hasher := sha256.New()
|
hasher := sha256.New()
|
||||||
|
@ -161,6 +161,15 @@ func (t *Theme) AddThemeStaticFiles() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// Don't use Gzip if we get meagre gains from it as it takes longer to process the responses
|
||||||
|
if len(gzipData) >= (len(data) + 150) {
|
||||||
|
gzipData = nil
|
||||||
|
} else {
|
||||||
|
diff := len(data) - len(gzipData)
|
||||||
|
if diff <= len(data)/100 {
|
||||||
|
gzipData = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get a checksum for CSPs and cache busting
|
// Get a checksum for CSPs and cache busting
|
||||||
hasher := sha256.New()
|
hasher := sha256.New()
|
||||||
|
Loading…
Reference in New Issue
Block a user