PHPackages                             vacatia/varnish-mobiletranslate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. vacatia/varnish-mobiletranslate

AbandonedArchivedLibrary[Caching](/categories/caching)

vacatia/varnish-mobiletranslate
===============================

03.4kPHP

Since Feb 19Pushed 7y ago4 watchersCompare

[ Source](https://github.com/vacatia/varnish-mobiletranslate)[ Packagist](https://packagist.org/packages/vacatia/varnish-mobiletranslate)[ RSS](/packages/vacatia-varnish-mobiletranslate/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (2)Used By (0)

Varnish Mobile Detect
=====================

[](#varnish-mobile-detect)

\###Goal: Drop-in varnish solution to mobile user detection based on the  library.

\###How: A VCL script that adds a `X-UA-Device` header to the request.

Device TypeX-UA-DevicePhonephoneTablettabletOtherdesktop\###Requirements Varnish 3 is a requirement. If you venture running this with Varnish 2, there is no gurantee for support. It is also helpful to know understand the basics of the VCL language and workflow. This is not a VMOD module, so no compiling is required.

\###Installation

1. Download the mobile\_detect.vcl file into your vcl config directory. `/etc/varnish/`

- `wget https://raw2.github.com/willemk/varnish-mobiletranslate/master/mobile_detect.vcl`

2. Include the `mobile_detect.vcl` in your `default.vcl` file (See examples below)
3. Call `devicedetect` from vcl\_recv in varnish (See examples below)

\###Usage ####Sample use case: Different back ends Using a different backend for mobile than for desktop

```
include "mobile_detect.vcl";

backend mobile {
    .host = "10.0.0.1";
    .port = "80";
}

sub vcl_recv {

    call devicedetect;

    if (req.http.X-UA-Device ~ "^mobile") {
        set req.backend = mobile;
    }
}

```

\####Sample use case: Normalize the user-agent string for the backend The backend receives the simplified user-agent generated by the mobile\_detect. The backend can then serve different content accordingly. It will then cache it by device type.

```
include "mobile_detect.vcl";

sub vcl_recv {

    call devicedetect;

    if (req.http.X-UA-Device) {
        set req.http.User-Agent = req.http.X-UA-Device;
        unset req.http.X-UA-Device;
    }
}

sub vcl_hash {
    #Default Hash
    hash_data(req.url);
    if (req.http.host) {
        hash_data(req.http.host);
    } else {
        hash_data(server.ip);
    }

    #Also hash based on device type
    if (req.http.X-UA-Device) {
        hash_data(req.http.X-UA-Device);
    }

    return (hash);
}

```

\####Sample use case: Cache based on device type If your backend generates the different content for the same URL based on device type, it should be cached accoding to that device type.

```
include "mobile_detect.vcl";

sub vcl_recv {

    call devicedetect;

}

sub vcl_hash {
    #Default Hash
    hash_data(req.url);
    if (req.http.host) {
        hash_data(req.http.host);
    } else {
        hash_data(server.ip);
    }

    #Also hash based on device type
    if (req.http.X-UA-Device) {
        hash_data(req.http.X-UA-Device);
    }

    return (hash);
}

```

\###Bugs &amp; Features

If you have any bug reports, feature request or want to submit a pull request, please use the appropriate github tools.

\###Thanks

Thanks to these projects for help and inspiration

\###Update mobile\_detect.vcl

You can update the mobile detection rules using latest from `serbanghita/Mobile-Detect`, by executing `php varnishtranslate.php`. Then push the `mobile_detect.vcl` to the repo.

###  Health Score

24

—

LowBetter than 30% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/647137?v=4)[Radu Topala](/maintainers/radutopala)[@radutopala](https://github.com/radutopala)

---

Top Contributors

[![willemk](https://avatars.githubusercontent.com/u/925449?v=4)](https://github.com/willemk "willemk (31 commits)")[![dbpolito](https://avatars.githubusercontent.com/u/347400?v=4)](https://github.com/dbpolito "dbpolito (2 commits)")[![radutopala](https://avatars.githubusercontent.com/u/647137?v=4)](https://github.com/radutopala "radutopala (2 commits)")[![carlbastos](https://avatars.githubusercontent.com/u/12959159?v=4)](https://github.com/carlbastos "carlbastos (1 commits)")

### Embed Badge

![Health badge](/badges/vacatia-varnish-mobiletranslate/health.svg)

```
[![Health](https://phpackages.com/badges/vacatia-varnish-mobiletranslate/health.svg)](https://phpackages.com/packages/vacatia-varnish-mobiletranslate)
```

###  Alternatives

[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)[phpfastcache/phpssdb

PHP SSDB Driver for phpFastCache

14736.9k1](/packages/phpfastcache-phpssdb)[rapidwebltd/rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

15196.8k7](/packages/rapidwebltd-rw-file-cache)[yuzuru-s/redis-recommend

Wrapping Redis's sorted set APIs for specializing recommending operations.

392.9k](/packages/yuzuru-s-redis-recommend)[ichhabrecht/intcache

Turn uncachable page objects into cacheable links

193.9k](/packages/ichhabrecht-intcache)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
