1
0
mirror of https://github.com/H0llyW00dzZ/My-RESTAPIs-Boilerplate.git synced 2025-02-06 09:26:02 +00:00

Enchance Static File serving & Update Git & Docker Ignore (#827)

* Enchance [Route] [Frontend] Static File serving

- [+] feat(frontend_routes): enable ByteRange and Compress options for static file serving

* Update Git & Docker Ignore

- [+] chore: add *.gz files to .dockerignore and .gitignore for cache compression

* Update Comment

- [+] chore(middleware): add comments about ByteRange enhancing QUIC in static file serving
This commit is contained in:
H0llyW00dzZ 2024-08-20 08:33:57 +07:00 committed by GitHub
parent 01c6ef4a31
commit 74e540794c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 0 deletions

View File

@ -71,3 +71,13 @@ gts-RootCA.pem
tailwind.css
# Go CSS Generator (not available yet).
tailwind.go
# Cache Compression (gzip)
#
# Note: When using the Cache Middleware with the WithCacheControl option set to true and a Storage provider (e.g., Redis or Valkey),
# the compressed files will be automatically stored in the specified Storage provider and sent to the client (browser).
# The compressed files are not stored in the server's memory.
#
# However, if the WithCacheControl option is set to false, the compressed files will be stored in the server's memory.
# In this case, it is recommended to implement a storage mechanism that stores the files on disk instead of memory to avoid excessive memory consumption.
*.gz

10
.gitignore vendored
View File

@ -94,3 +94,13 @@ gts-RootCA.pem
tailwind.css
# Go CSS Generator (not available yet).
tailwind.go
# Cache Compression (gzip)
#
# Note: When using the Cache Middleware with the WithCacheControl option set to true and a Storage provider (e.g., Redis or Valkey),
# the compressed files will be automatically stored in the specified Storage provider and sent to the client (browser).
# The compressed files are not stored in the server's memory.
#
# However, if the WithCacheControl option is set to false, the compressed files will be stored in the server's memory.
# In this case, it is recommended to implement a storage mechanism that stores the files on disk instead of memory to avoid excessive memory consumption.
*.gz

View File

@ -47,6 +47,9 @@ func registerStaticFrontendRoutes(app *fiber.App, _ string, _ database.Service)
// Note: This is an example, and the unused parameters are assigned to "_" to avoid compiler errors.
// Register static file serving
app.Static("/styles/", "./frontend/public/assets", fiber.Static{
// This "ByteRange" Enhance QUIC
ByteRange: true,
Compress: true,
// Note: When running on K8S don't have to compress because it will handled by nginx or other controller.
// Compress: true, // Optional
// Note: It's important to disable this when using middleware cache to avoid confusion,

View File

@ -246,6 +246,7 @@ func registerRouteConfigMiddleware(app *fiber.App, db database.Service) {
func registerRootRouter(app *fiber.App) {
// Register static file serving
app.Static("/styles/", "./frontend/public/assets", fiber.Static{
// This "ByteRange" Enhance QUIC
ByteRange: true,
Compress: true,
// optional