PHPackages                             dereuromark/cakephp-url-cache - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. dereuromark/cakephp-url-cache

ActiveCakephp-plugin[Utility &amp; Helpers](/categories/utility)

dereuromark/cakephp-url-cache
=============================

CakePHP plugin to speed up URL reverse lookup

1.0.0(11y ago)24117.2k5MITPHPPHP &gt;=5.4

Since Apr 15Pushed 10y ago2 watchersCompare

[ Source](https://github.com/dereuromark/cakephp-url-cache)[ Packagist](https://packagist.org/packages/dereuromark/cakephp-url-cache)[ Docs](https://github.com/dereuromark/cakephp-url-cache)[ RSS](/packages/dereuromark-cakephp-url-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

CakePHP UrlCache plugin
=======================

[](#cakephp-urlcache-plugin)

[![Build Status](https://camo.githubusercontent.com/40b79418c67cd7cd2b5707984f73f460740a032264382209145ff822f256cf9a/68747470733a2f2f6170692e7472617669732d63692e6f72672f6465726575726f6d61726b2f63616b657068702d75726c2d63616368652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/dereuromark/cakephp-url-cache)[![Latest Stable Version](https://camo.githubusercontent.com/870d2f41f5cf5912044e2139a471281554aa444eefff0a0cf10c59b50c4645c6/68747470733a2f2f706f7365722e707567782e6f72672f6465726575726f6d61726b2f63616b657068702d75726c2d63616368652f762f737461626c652e706e67)](https://packagist.org/packages/dereuromark/cakephp-url-cache)[![Coverage Status](https://camo.githubusercontent.com/f48371e94c7018989d0c50aff29147cdd7bd243ce548c96fd0c6b641ac0347dd/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6465726575726f6d61726b2f63616b657068702d75726c2d63616368652f62616467652e706e67)](https://coveralls.io/r/dereuromark/cakephp-url-cache)[![Minimum PHP Version](https://camo.githubusercontent.com/b8feeff753e7c6ff51ffd26c612be3c4f292513e413cd0c8884e665ff51dd798/687474703a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230352e342d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/2573efee7c1fb9540efef015d947098116d6c60dfb789634d93d931858c30db1/68747470733a2f2f706f7365722e707567782e6f72672f6465726575726f6d61726b2f63616b657068702d75726c2d63616368652f6c6963656e73652e706e67)](https://packagist.org/packages/dereuromark/cakephp-url-cache)[![Total Downloads](https://camo.githubusercontent.com/46f70092c377b0cf671c5eaf3cf02c5e03b6adc5e7b6d1ac89ab1fb5df333f5e/68747470733a2f2f706f7365722e707567782e6f72672f6465726575726f6d61726b2f63616b657068702d75726c2d63616368652f642f746f74616c2e706e67)](https://packagist.org/packages/dereuromark/cakephp-url-cache)

For CakePHP 2.x

Whenever you use `$this->Html->link()` in your CakePHP views the CakePHP Router has to scan through all your routes until it finds a match. This can be slow if you have a lot of links on a page or use a lot of custom routes. By adding this code to your AppHelper the URLs are cached, speeding up requests. The cache settings follow the same rules as the other CakePHP core cache settings. If debug is set to greater than 0 the cache expires in 10 seconds. With debug at 0 the cache is good for 999 days.

Instructions
------------

[](#instructions)

1. Download the plugin to `app/Plugin/UrlCache` manually or include it via composer.
2. Put at the top of your `app/View/Helper/AppHelper.php`:

    ```
    App::uses('UrlCacheAppHelper', 'UrlCache.View/Helper');
    ```
3. Load and activate Plugin in `app/Config/bootstrap.php`:

    ```
    CakePlugin::load('UrlCache');

    Configure::write('UrlCache.active', true);
    ```
4. Have your AppHelper extend UrlCacheAppHelper instead of Helper:

    ```
    class AppHelper extends UrlCacheAppHelper {
        ...
    }
    ```
5. That's it! Just continue using `$this->Html->link()` or `$this->Html->url()` as you usually do.

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

[](#configuration)

By default all the cache will be stored in one file. This is only recommended for sites with not many links. If your site has a ton of unique URLs you don't want to store them all in one giant cache which would need to be loaded each request. So in case you have a large amount of links on specific pages, and if they contain more than just the main URL fragments (prefix, plugin, controller, action) like with pagination you can set the option `Configure::write('UrlCache.pageFiles', true)`and each page will additionally keep a separate cache for those unique URLs. Only the controller/action URLs without named or passed params will then be stored in the global cache.

There is also a `Configure::write('UrlCache.verbosePrefixes', true)` param. It is useful if you defined some prefixes in your core.php like `Configure::write('Routing.prefixes', ['admin']);`and if you mainly still use the old 1.2/1.3 syntax for prefixes:

```
'admin' => true/false

```

instead of

```
'prefix' => 'admin'

```

The latter is more future proof, though.

Debugging
---------

[](#debugging)

With the de-facto-standard debugging tool [DebugKit](https://github.com/cakephp/debug_kit) you can enable a toolbar panel that allows you to see how many links have been used and/or added per page view. To enable it, you can add it to your $components configuration:

```
public $components = ['DebugKit.Toolbar' => ['panels' => ['UrlCache.UrlCache']]];

```

Benchmark
---------

[](#benchmark)

With a little sample script you can at least approximate the improvement for your (custom) routes:

```
// In your view ctp:
$timeStart = microtime(true);

$url = ['controller' => 'posts', 'action' => 'view'];
for ($i = 0; $i < 10000; $i++) {
	$u = $url;
	$u[] = $i;
	$link = $this->Html->link($i, $u);
}

$timeEnd = microtime(true);
$time = $timeEnd - $timeStart;
debug($time);
```

With the first request with my test it was 9 seconds, the second hit only 1 second. So in overall the speed improvement can be **around 10x faster**. It really depends on how dynamic your pages and URLs are, though. And the above 10000 links is not a realistic scenario, so the overall speed improvement compared to the whole dispatcher process will be usually a lot less. So you definitely should look into other bottlenecks, usually the DB, opcode caching, and dispatching speed in general.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Unknown

Total

1

Last Release

4052d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/39854?v=4)[Mark Scherer](/maintainers/dereuromark)[@dereuromark](https://github.com/dereuromark)

---

Top Contributors

[![lorenzo](https://avatars.githubusercontent.com/u/37621?v=4)](https://github.com/lorenzo "lorenzo (8 commits)")[![josegonzalez](https://avatars.githubusercontent.com/u/65675?v=4)](https://github.com/josegonzalez "josegonzalez (5 commits)")[![mcurry](https://avatars.githubusercontent.com/u/29715?v=4)](https://github.com/mcurry "mcurry (3 commits)")[![dereuromark](https://avatars.githubusercontent.com/u/39854?v=4)](https://github.com/dereuromark "dereuromark (3 commits)")[![drmonkeyninja](https://avatars.githubusercontent.com/u/357623?v=4)](https://github.com/drmonkeyninja "drmonkeyninja (2 commits)")[![Phally](https://avatars.githubusercontent.com/u/112639?v=4)](https://github.com/Phally "Phally (1 commits)")[![mromagnoli](https://avatars.githubusercontent.com/u/1746271?v=4)](https://github.com/mromagnoli "mromagnoli (1 commits)")[![ceeram](https://avatars.githubusercontent.com/u/111448?v=4)](https://github.com/ceeram "ceeram (1 commits)")

---

Tags

helpercakephprouting

### Embed Badge

![Health badge](/badges/dereuromark-cakephp-url-cache/health.svg)

```
[![Health](https://phpackages.com/badges/dereuromark-cakephp-url-cache/health.svg)](https://phpackages.com/packages/dereuromark-cakephp-url-cache)
```

###  Alternatives

[torifat/cake-menu_builder

A dynamic menu building helper for CakePHP 2.x

755.6k](/packages/torifat-cake-menu-builder)[drmonkeyninja/cakephp-social-share

CakePHP helper for creating social share/bookmark links

34103.3k](/packages/drmonkeyninja-cakephp-social-share)[codaxis/cakephp-bootstrap3-helpers

CakePHP highly configurable helpers for Bootstrap 3 framework.

4111.5k2](/packages/codaxis-cakephp-bootstrap3-helpers)[dereuromark/cakephp-calendar

A CakePHP plugin to easily create calendars.

1646.8k1](/packages/dereuromark-cakephp-calendar)

PHPackages © 2026

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