PHPackages                             tugrul/http-cache-bundle - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. tugrul/http-cache-bundle

ActiveLibrary[HTTP &amp; Networking](/categories/http)

tugrul/http-cache-bundle
========================

symfony http cache bundle

1.0.5(1y ago)018proprietaryPHPPHP &gt;=8.1

Since Nov 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/tugrul/HttpCacheBundle)[ Packagist](https://packagist.org/packages/tugrul/http-cache-bundle)[ RSS](/packages/tugrul-http-cache-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (5)Versions (6)Used By (0)

Tug HTTP Cache Bundle
=====================

[](#tug-http-cache-bundle)

The **Tug HTTP Cache Bundle** is a Symfony bundle that enhances HTTP caching by managing `ETag` and `Last-Modified` headers at the router and parameter level. It allows for fine-grained control over cacheable responses, optimizing caching for both client-side and proxy servers like Nginx and Varnish.

---

Features
--------

[](#features)

- Cache management by route and allowed parameters.
- Automatic handling of `ETag` and `Last-Modified` headers.
- Efficient validation for `304 Not Modified` responses.
- Seamless integration with proxy cache servers like Nginx and Varnish.
- Configurable global and route-specific caching behavior.

---

Installation
------------

[](#installation)

Install the bundle using Composer:

```
composer require tugrul/http-cache-bundle
```

---

Configuration
-------------

[](#configuration)

### Define a Cache Pool

[](#define-a-cache-pool)

First, define a cache pool for the bundle to store ETag and Last-Modified values:

```
# config/packages/cache.yaml

framework:
  cache:
    pools:
      cache.tug_http_cache:
        adapter: cache.adapter.filesystem
```

### Add Bundle Configuration

[](#add-bundle-configuration)

Next, configure the bundle according to your application's caching requirements:

```
# config/packages/tug_http_cache.yaml

tug_http_cache:
  ignored_param_names:
    - worthless_param_name

  allowed_param_names:
    _locale: en
    amp: false

  routes:
    - name: index
    - name: blog_post_index
      allowed_query_names:
        page: 1  # default query value if not present in the request
    - name: blog_post_detail
      allowed_param_names:
        slug: null
```

### Configuration Options

[](#configuration-options)

- **`ignored_param_names`**: Parameters to ignore when building cache keys.
- **`allowed_param_names`**: Globally allowed parameters with their default values.
- **`routes`**: Route-specific cache configuration.
    - **`name`**: The route name.
    - **`allowed_query_names`**: Query parameters allowed for this route.
    - **`allowed_param_names`**: Parameters allowed for this route, with optional default values.

---

Usage
-----

[](#usage)

Once configured, the bundle:

1. **Checks Cache**: For incoming requests, it checks if a cached response exists based on the route and allowed parameters.
2. **Validates Cache**: If the cache exists, it validates the `ETag` and `Last-Modified` headers to decide whether to return a `304 Not Modified` response.
3. **Captures Response**: For cacheable responses, it automatically generates `ETag` and `Last-Modified` headers and stores them for future use.

---

Example
-------

[](#example)

### Example Route

[](#example-route)

Define routes in your application:

```
# config/routes.yaml

index:
  path: /
  controller: App\Controller\IndexController::index

blog_post_index:
  path: /blog
  controller: App\Controller\BlogController::index

blog_post_detail:
  path: /blog/{slug}
  controller: App\Controller\BlogController::detail
```

### Example Controller

[](#example-controller)

Ensure your responses are cacheable:

```
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class BlogController extends AbstractController
{
    public function index(): Response
    {
        $response = $this->render('blog/index.html.twig');
        $response->setPublic();
        $response->setMaxAge(3600); // Cache for 1 hour

        return $response;
    }

    public function detail(string $slug): Response
    {
        $response = $this->render('blog/detail.html.twig', ['slug' => $slug]);
        $response->setPublic();
        $response->setMaxAge(3600);

        return $response;
    }
}
```

### Proxy Server Configuration

[](#proxy-server-configuration)

For Nginx or Varnish, ensure they are configured to respect `ETag` and `Last-Modified` headers for caching.

---

Contributing
------------

[](#contributing)

Contributions are welcome! Please submit issues or pull requests via the [GitHub repository](https://github.com/tugrul/HttpCacheBundle).

---

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

---

Support
-------

[](#support)

If you encounter any issues or have questions, feel free to open an issue on GitHub or contact the maintainer directly.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~1 days

Total

5

Last Release

530d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8203eaef0737a157a828b37dc85a63defa0d26e3f215135fe76cff6c67d2fa20?d=identicon)[tugrul](/maintainers/tugrul)

---

Top Contributors

[![tugrul](https://avatars.githubusercontent.com/u/163442?v=4)](https://github.com/tugrul "tugrul (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tugrul-http-cache-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tugrul-http-cache-bundle/health.svg)](https://phpackages.com/packages/tugrul-http-cache-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M309](/packages/easycorp-easyadmin-bundle)[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M192](/packages/simplesamlphp-simplesamlphp)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/storefront

Storefront for Shopware

684.2M148](/packages/shopware-storefront)

PHPackages © 2026

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