Server-side optimization of uploaded images: WebP, AVIF, compression

Heavy images quietly eat away at site speed and conversion, and visitors leave before waiting for them to load. We set up turnkey server-side image optimization: we select formats and delivery modes, build caching and guidelines. Delivery speeds up several times over, and drops under peak load disappear.

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Frequently Asked Questions

Server-side image optimization: where delivery breaks

Heavy source files are the most common reason a site "seems to work" but loads slowly. A photo gallery, a product card catalog, a news feed: files were uploaded once at their original resolution and have been served as-is ever since.

The browser receives an image several thousand pixels wide where a quarter of that would suffice, and pulls it even on a smartphone screen.

Server response time stays normal in this case — the bottleneck isn't in the backend, but in static file delivery: the server honestly and quickly sends megabytes that the client doesn't need.

Then the mobile scenario kicks in. On a cellular network, such a page reaches first paint several times slower, some requests time out, and the bounce rate on phones grows faster than on desktop.

The user doesn't wait for the image and leaves — conversion drops for no apparent reason, even though everything is functionally sound.

Server-side image optimization addresses this at the delivery level, not in the markup: the server itself determines the appropriate format from the browser's headers, serves a modern codec with a fallback, and scales to the actual screen size. The source file stays untouched in storage — only what goes to the client changes.

Let's break down how this works: exactly where time is lost, which formats to serve and in what order, how not to break the cache, and what to do with an already accumulated archive of heavy files.

What server-side image optimization delivers in practice

The effect is measured across four metrics: the compression ratio relative to the source, the server-side response generation time, behavior under load, and which class of failures is eliminated.

In practice, switching to modern formats and proper size slicing reduces the delivered weight by 2-4 times on photo content — even though the difference is visually imperceptible. A catalog with a hundred cards stops serving megabytes where tens of kilobytes would suffice.

Response generation time changes not because of "format magic," but because the heavy lifting moves out of the request.

Variants are encoded once and placed in cache — on a repeat request, the server serves a ready-made file instead of re-compressing the source on every request. Hence the predictable latency: the first run is more expensive, all subsequent ones are cheap.

If you encode on the fly, under peak load the server starts spending resources on compression instead of delivery, and response time grows along with the queue.

Stability under load is a direct consequence. Less response weight means less time the channel and worker are occupied, and higher throughput on the same hardware.

The specific class of failures eliminated here is timeouts on mobile networks and interrupted downloads of large files. When an image weighs several times less, it reaches the client on the first try, and the user doesn't see a "broken" tile in the catalog.

A separate class of failures is closed off — the one related to storage growth: if you don't limit the set of derived sizes, the number of files grows faster than the content.

A policy of a fixed set of widths and formats keeps the volume predictable, while Sharp on the server side handles both slicing and encoding in a single pass — with no manual work by a content manager on every image.

Delivery formats and modes: comparison of approaches

Choosing a format is a trade-off between file weight, image quality, and which browsers will even display it. Below are the working options that teams actually choose between on projects, and their limitations.

Option When it fits Limitations
Classic formats (JPEG, PNG) Maximum compatibility, a simple stack without rebuilding assets Weight is 2-4 times higher than modern formats, JPEG has no transparency, PNG is heavy for photos
Modern formats (WebP, AVIF) Main traffic comes from current browsers, speed and traffic matter AVIF takes longer to encode, some older clients won't display the image without a fallback
Hybrid delivery based on client capabilities Public sites with a broad audience where you can't afford to lose anyone Requires generating multiple versions and correct negotiation headers

The hybrid scheme is what we set by default on public projects. The server stores a single source, and at delivery time generates versions in modern formats and serves them via the content negotiation header; if the client doesn't support them, a classic file is sent instead. The browser itself reports what it can handle, so broken images never happen.

Quality and weight are configured separately for each format: for photos we keep a visually indistinguishable compression level, for graphics and icons — lossless.

This gives a predictable result: the page serves lightweight images to those who understand them, and doesn't lose its audience on older devices.

Server-side implementation procedure

Implementing server-side image optimization is not about installing a single extension, but a sequence of steps where each subsequent one relies on the data from the previous one.

We start with an audit of delivery: we look at which formats and volumes actually go out to clients, where time is lost on compression, how the cache is structured, and how many requests fall on a single layout. Without these figures, any configuration turns into guesswork.

  1. Audit of current delivery. We capture a traffic profile: the share of heavy formats, the average page weight, the distribution of requests between mobile and desktop clients. We identify the points where compression happens on the fly and hurts server responsiveness.
  2. Designing the processing scheme. We determine where conversion will sit — at upload to storage or on request — which formats we generate (WebP, AVIF), and how we serve them taking into account browser support. We plan result caching so that repeated requests do not trigger compression again.
  3. Server configuration. We connect conversion, set up delivery rules based on format negotiation headers, quality and size limits, and the retention policy for source and derivative files. We address rollback separately: the original images remain untouched.
  4. Verifying the result. We compare weight and delivery speed before and after on real pages, check visual quality at different resolutions, and make sure that older clients receive a compatible format without errors.
  5. Handing over the regulations. We prepare documentation: how to add new formats, which cache rules apply, and what to do when the load grows. The client's team receives instructions so they can maintain the scheme without us.

This procedure delivers a predictable result: the volume of transmitted images drops severalfold, and the server stops spending resources on compression at the moment of request. Describe your task — we will come back with an estimate and a work plan.

Configurations, caching policies, and operational procedures

After implementing server-side image optimization, a set of artifacts remains that make the system operable, transferable to another team, and reproducible in a new environment.

Without them, optimization survives only until the first server update or contractor change — and rolls back to its original state. Below is what exactly gets documented.

  • Server configurations: compression module parameters, re-encoding rules for WebP and AVIF, limits on source size and resolution, behavior when the client side does not support a format.
  • Processing pipelines: the image's path from upload to delivery — where conversion happens, where the original is stored, how derived sizes are generated, and how they are invalidated when a file is replaced.
  • Caching policies: time-to-live for originals and derivatives, cache-control headers, purge rules on content updates, CDN behavior on a miss.
  • Operational procedures: the process for adding new formats and sizes, storage growth control, actions to take when quality degrades or delivery time increases.
  • Team documentation: configuration map, monitoring points, instructions for rolling back to the previous processing pipeline.
  • Acceptance checklist: a set of reference images and baseline compression results used to verify correctness after any changes.

Each item covers its own class of failures: configurations — desynchronization between environments, cache policies — stale versions for users, procedures — uncontrolled storage growth.

Such a kit allows changing the processing pipeline predictably, rather than by trial and error on live traffic.

Describe your task — we will get back to you with an estimate and a plan for which artifacts are needed specifically for your stack and traffic volume.

Case study: how we reduced response weight and eliminated slowdowns

The project was a catalog with product cards and a heavy gallery: each page pulled full-size images in their original format, and the response for a single catalog page reached 8–12 MB.

On mobile networks this resulted in an LCP of around 6–9 seconds, and under peak load the server hit the channel limit and returned some requests with errors — the class of failures we set out to eliminate.

What we did

We deployed on-the-fly server-side processing: on the first request, the image is re-encoded into WebP and AVIF, placed in the cache, and thereafter served already prepared.

The format is selected based on the Accept header, and for older clients the original file remains as a fallback.

In parallel, we rebuilt the size grid — instead of a single "universal" image, variants are generated for the actual layout breakpoints, and unnecessary previews were removed.

Metrics before and after

Metric Before After
Catalog page weight 8–12 MB 1.4–2.1 MB
Compression ratio — 78–84%
LCP on mobile 6–9 s 1.8–2.4 s
Server response time (p95) 900–1400 ms 180–260 ms
Delivery errors at peak 3–5% of requests isolated cases

The 78–84% compression ratio is not an "average across the board": on photos with smooth gradients AVIF delivers more, while on graphics with sharp edges it delivers less, so we calculated based on real traffic rather than a test sample.

What changed for the business

Response time dropped severalfold, and the server stopped being a bottleneck — the same instance handles peak load without delivery errors.

The class of failures that previously surfaced specifically during sale hours is gone: pages open consistently, and search engines see a fast site and rank it higher.

We worked on Cloudflare — caching and re-encoding at the edge take the load off the primary server, and the client gets predictable delivery regardless of traffic spikes.

How does server-side optimization differ from client-side optimization?

Client-side optimization is everything that happens in the browser after the file has arrived over the network: lazy loading via loading="lazy", responsive delivery via srcset and sizes, deferred rendering, caching on the user's device.

The browser decides when to request an image and which of the prepared versions to use for the current screen. But it cannot do what it does not have: if the server holds a single 4 MB JPEG, no srcset will make it lighter.

Server-side optimization is the point where effort is applied before the file is served: generating WebP and AVIF from the source, selecting compression quality based on the image type, slicing into size variants, and serving the required format based on the Accept header.

Here the boundary of responsibility runs along the network: the server is responsible for how much data will actually be sent to the client, and the client is responsible for when and with what priority it fetches it.

The practical meaning of this separation is that these two layers cure different diseases. Client-side techniques eliminate unnecessary requests and spread loading out over time, but they do not touch the weight of each individual image.

Server-side techniques reduce weight many times over: converting to a modern format and correct compression yield a multiple reduction in volume with a visually indistinguishable result.

If you confuse the layers, a typical mistake is spending years tweaking lazy loading on a page where every image weighs like wallpaper, and being surprised that speed does not improve.

There is also a reverse dependency: server-side optimization only reveals its value together with client-side optimization. Sliced variants are useless if the markup cannot request them; modern formats will not help if the image loads in the first viewport without priority.

Therefore the boundary is not about "either-or," but about order: first the server brings the weight down to something reasonable, then the client manages the order and timing of delivery.

Common technical concerns

Let's go through the typical technical concerns that come up before starting. Below are our engineers' answers based on their experience with server-side image optimization: compatibility, migration, rollback, and access.

Will the layout break on older browsers?

No. We serve modern formats through server-side format negotiation: a browser receives WebP or AVIF only if it has requested them itself, while everyone else gets the original JPEG or PNG. We also keep a fallback path via the <picture> tag with multiple sources. The layout and embedded widgets work the same across the entire fleet of devices.

What happens to images that are already uploaded?

We don't blindly overwrite old files. First we run them through batch processing into separate storage, verify visual quality on a control sample, and only then switch the delivery. The originals are preserved — you can return to them at any time.

How do we roll back changes if something goes wrong?

Optimization lives at the level of the delivery configuration, not in the page code. A rollback means reverting to the previous processing profile: a single configuration edit, with no application rebuild. We keep both profiles in parallel, so switching takes minutes.

Is access to servers and the CDN required?

Setup requires access to the web server configuration and the CDN panel, as well as to the image storage. We work in a separate configuration branch, and changes are validated in a test environment. We touch the production environment only after approval.

How much will image quality drop?

With correct compression parameters, the difference is invisible to the eye on photos and interface graphics. For logos and icons we use lossless compression, and for photos a configurable level. File size drops severalfold, and the page delivers content noticeably faster.

If your question isn't here — describe the task, and we'll get back to you with an estimate and a plan.

Let's discuss your task and come back with an estimate

To come back with an estimate and a plan, we need a minimum of input: where the images live now, who serves them, and what has already been tried. Describe the task in free form — then we'll ask clarifying questions that are to the point, not from a questionnaire.

What helps us get started faster:

  • a list of image types: product cards, galleries, banners, avatars, user uploads — each has its own compression policy and set of formats;
  • where the source files come from: uploads via the admin panel, import from a catalog, on-the-fly generation — this determines where to place transcoding;
  • current infrastructure: a single server, a load balancer, a CDN, object storage — this influences the choice between on-the-fly transcoding and pre-generation;
  • examples of "heavy" pages with URLs and measurements — they show exactly where loading time is lost;
  • quality requirements: where loss of detail is acceptable and where visual accuracy is needed (for example, product photos);
  • access and compliance constraints: who owns the domain, whether there is a separate environment for test runs;
  • expectations for timelines and priorities: what is critical to address first and what can be moved to a second wave.

As a result, you will receive a work plan with stages, a layout diagram of transcoding relative to storage and delivery, a list of formats and compression rules for your content types, as well as a rollout procedure with the ability to roll back at every step.

Separately, we will define how we will measure the result: the share of traffic in new formats, page weight, and time to display the main content.

Describe the task — we'll come back with an estimate and a plan.

Our competencies:

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1393
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1368
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1139
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1152
  • Website development for SBH Partners
    Website development for SBH Partners
    1231
  • Website development for Red Pear
    Website development for Red Pear
    641