Frontend Development 12 min read

How Frontend Zip Compression Can Boost Performance and Reduce Server Load

This article explores the history of ZIP, the challenges of exporting large Excel files from PHP front‑ends, and how using zip.js with HTML5 File API and web workers enables a half‑asynchronous, client‑side compression workflow, outlining its benefits, limitations, and practical considerations for frontend developers.

Yuewen Technology
Yuewen Technology
Yuewen Technology
How Frontend Zip Compression Can Boost Performance and Reduce Server Load

Remembering Phil Katz, the Father of ZIP

Before diving into the technical discussion, the article pays tribute to Phil Katz, the creator of the ZIP compression algorithm, highlighting his contributions and legacy in the computing world.

Why Exporting Excel from the Frontend Can Time Out

Exporting large datasets to Excel directly from PHP front‑ends often leads to 504 Gateway Timeout errors due to PHP’s limitations and Nginx’s execution time caps, causing poor user experience.

Traditional Asynchronous Export Solution

The common approach separates the request and download phases: the frontend records the export request, while backend services (Java, Python, etc.) generate the Excel file asynchronously and store it for later download.

Half‑Asynchronous Approach with zip.js

This method keeps the frontend request asynchronous but performs the final file generation synchronously using the zip.js library, which relies on HTML5 File API (FileReader, Blob) and TypedArray, supported by most modern browsers except IE 9 and below.

zip.js provides an HttpReader class that fetches resources via URL, first sending a HEAD request to obtain file size, then a GET request to download the data, avoiding long server‑side processing.

The core compression uses the open‑source deflate algorithm (based on LZ77 and Huffman coding), offering faster speed than RAR despite slightly lower compression ratios, and being freely available for client‑side use.

Because JavaScript runs on a single thread, heavy compression is offloaded to Web Workers, which operate like background threads and communicate via postMessage and onmessage , preventing the UI from freezing.

Using zip.js on the client reduces server load, eliminates the need for server‑side compression storage, simplifies development, and provides visible download progress, making it suitable for assets like audio, video, images, and periodic reports.

However, client‑side compression can be CPU‑intensive, potentially causing browser slowdown or crashes on low‑end machines, and requires the browser to stay open for the entire process, which may affect user experience and bandwidth usage.

Conclusion

The article concludes that while front‑end ZIP compression offers clear advantages such as reduced server pressure and improved user feedback, developers must weigh its CPU demands, browser compatibility, and network considerations before adopting it as a solution.

frontendjavascriptweb workersasynchronous exportzip compression
Yuewen Technology
Written by

Yuewen Technology

The Yuewen Group tech team supports and powers services like QQ Reading, Qidian Books, and Hongxiu Reading. This account targets internet developers, sharing high‑quality original technical content. Follow us for the latest Yuewen tech updates.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.