Challenge - 5 Problems
Gzip Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the effect of this gzip configuration snippet?
Given this nginx configuration snippet:
What happens when a client requests a JSON file of 800 bytes?
gzip on; gzip_types text/plain application/json; gzip_min_length 1000;
What happens when a client requests a JSON file of 800 bytes?
Nginx
gzip on;
gzip_types text/plain application/json;
gzip_min_length 1000;Attempts:
2 left
💡 Hint
Check the minimum length setting and file size.
✗ Incorrect
The gzip_min_length directive sets the minimum size in bytes for compression. Since 800 bytes is less than 1000, the file is sent uncompressed even if its type matches gzip_types.
🧠 Conceptual
intermediate2:00remaining
Which MIME types will be compressed with this configuration?
Consider this nginx gzip configuration:
Which of the following file types will be compressed?
gzip on; gzip_types text/css application/javascript image/svg+xml;
Which of the following file types will be compressed?
Nginx
gzip on; gzip_types text/css application/javascript image/svg+xml;
Attempts:
2 left
💡 Hint
gzip_types controls which MIME types are compressed.
✗ Incorrect
The gzip_types directive lists MIME types that nginx compresses. Here, text/css, application/javascript, and image/svg+xml are included, so these types will be compressed.
❓ Troubleshoot
advanced2:00remaining
Why is gzip compression not applied to HTML files despite gzip on?
An nginx server has this configuration:
Clients report HTML files are not compressed. Why?
gzip on; gzip_types text/css application/javascript;
Clients report HTML files are not compressed. Why?
Nginx
gzip on; gzip_types text/css application/javascript;
Attempts:
2 left
💡 Hint
Check which MIME types are listed in gzip_types.
✗ Incorrect
By default, nginx only compresses MIME types listed in gzip_types. Since text/html is not included, HTML files are not compressed even if gzip is on.
✅ Best Practice
advanced2:00remaining
What is the recommended minimum gzip_min_length value to avoid compressing very small files?
Which gzip_min_length value is best to avoid wasting CPU compressing tiny files?
Attempts:
2 left
💡 Hint
Small files often do not benefit from compression.
✗ Incorrect
Setting gzip_min_length to 1000 bytes or more avoids compressing very small files that do not gain much size reduction but consume CPU.
🔀 Workflow
expert3:00remaining
Order the steps to enable gzip compression for JSON files larger than 500 bytes in nginx
Arrange these steps in the correct order to configure nginx to gzip compress JSON files only if they are larger than 500 bytes.
Attempts:
2 left
💡 Hint
Enable gzip first, then configure types and size, finally reload.
✗ Incorrect
First enable gzip, then specify MIME types to compress, set minimum length, and finally reload nginx to apply.