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

[Download] Feature Request: GZIP Support #6

Open
Christopher-Hayes opened this issue Mar 1, 2021 · 2 comments
Open

[Download] Feature Request: GZIP Support #6

Christopher-Hayes opened this issue Mar 1, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Christopher-Hayes
Copy link

Christopher-Hayes commented Mar 1, 2021

Description

When it comes to hosting PlayCanvas yourself, using GZIP to speed up the delivery of asset files is a must. Since pulling down project builds and gzipping tend to be done in the same workflow, it would be nice if this tool could also GZIP your assets for you.

Where GZIP'ing is needed

GZIP'ing is typically not needed if a CDN is in use because most CDNs will do the gzipping automatically for you. However, if you're not using a CDN, for example your own server without a CDN or files directly linked to AWS S3, it is critical to GZIP assets to significantly reduce asset delivery time.

How GZIP'ing can be done

There's a few ways that GZIP'ing is done. I've found the easiest method is to just GZIP all files in a project, so you don't have to come up with a way to tell the host (such as AWS S3) which assets are GZIP compressed and which are not. However, it should be noted that video files, like MP4, cannot be GZIP compressed under any condition because they are delivered to the client in chunks. In a PlayCanvas project I think it would be most logical to GZIP only the assets. So, I think this feature would need to give you the option of gzipping either the whole project, certain file types, or just assets.

Example of how I'm using GZIP

If it helps, this is how I use GZIP in my workflow:

  1. Ask PlayCanvas for build of project.
  2. Download project from PlayCanvas.
  3. GZIP all PlayCanvas files in Bash. The command below just means GZIP files with the greatest compression levels and replace the original file with the gzipped version.
find "${playcanvas_dir}" -type f -exec gzip -9 {} \; -exec mv {}.gz {} \;
  1. Push to AWS S3 with GZIP content-encoding set.
aws s3 cp "${playcanvas_dir}/" s3://s3-bucket/ --recursive --include "*" --content-encoding "gzip"

Important note about GZIP

GZIP has to be done in conjunction with telling your server or host that these files are already GZIP'd. Failing to do this means your host will serve these GZIP files as if they are uncompressed and browsers will be unable to use the files since they don't know that they're compressed. That's why, while GZIP should be used whenever possible, if your CDN or server that GZIPs on-the-fly does it already, don't bother doing it ahead of time.

@Christopher-Hayes
Copy link
Author

Extra note:
I forgot to mention this, it's somewhat important. I said most CDNs will GZIP. An issue I did run into (ie the CDN Netlify uses), is that the 3D assets might not get GZIP'd even though the CDN supports GZIP'ing. CDNs will often look for specific file formats to GZIP and something like .dds may not get GZIP'd even though it absolutely needs to be. This is another reason for doing GZIP'ing manually.

@yaustar yaustar self-assigned this Mar 31, 2021
@yaustar yaustar added enhancement New feature or request good first issue Good for newcomers labels Mar 31, 2021
@yaustar
Copy link
Collaborator

yaustar commented May 14, 2021

@yaustar yaustar changed the title Feature Request: GZIP Support [Download] Feature Request: GZIP Support May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants