Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Etag support for embedded content #7132

Merged
merged 2 commits into from
Dec 9, 2023
Merged

Conversation

nopcoder
Copy link
Contributor

@nopcoder nopcoder commented Dec 9, 2023

Scan embedded content on startup and serve etag header to FileServer. FileServer will use the Etag and provide no content change if needed.

This will allow cache all static resources, which allow better performance after the first load, in the web ui.

Close #7131

Scan embedded content on startup and serve etag header to FileServer.
FileServer will use the Etag and provide no content change if needed.

This will allow cache all static resources, which allow better
performance after the first load, in the web ui.
@nopcoder nopcoder added the area/UI Improvements or additions to UI label Dec 9, 2023
@nopcoder nopcoder self-assigned this Dec 9, 2023
@nopcoder nopcoder requested a review from a team December 9, 2023 08:01
@nopcoder nopcoder added the include-changelog PR description should be included in next release changelog label Dec 9, 2023
Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments

@@ -34,7 +33,7 @@ func NewUIHandler(gatewayDomains []string, snippets []params.CodeSnippet) http.H
panic(err)
}
fileSystem := http.FS(injectedContent)
nocacheContent := middleware.NoCache(http.StripPrefix("/", http.FileServer(fileSystem)))
nocacheContent := EtagMiddleware(injectedContent, http.StripPrefix("/", http.FileServer(fileSystem)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modify variable name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - I missed that

}
defer func() { _ = f.Close() }()

h := md5.New()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// #nosec

Copy link
Contributor Author

@nopcoder nopcoder Dec 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking if crc32 will do a better work here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keeping the md5

package api

import (
"crypto/md5"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// #nosec

@nopcoder nopcoder requested a review from N-o-Z December 9, 2023 11:19
Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@nopcoder nopcoder merged commit 315770a into master Dec 9, 2023
34 checks passed
@nopcoder nopcoder deleted the chore/ui-embedded-etag branch December 9, 2023 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/UI Improvements or additions to UI include-changelog PR description should be included in next release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve performance of embedded content by adding UI Etag support
2 participants