Giter VIP home page Giter VIP logo

url_cache's Introduction

/*
 * App Helper Url Caching
 * Copyright (c) 2011 Matt Curry
 * www.PseudoCoder.com
 * http://github.com/mcurry/url_cache
 * http://www.pseudocoder.com/archives/how-to-save-half-a-second-on-every-cakephp-requestand-maintain-reverse-routing
 *
 * @author      Matt Curry <[email protected]>
 * @license     MIT
 *
 */

/* Description */
Whenever you use $html->link() in your CakePHP views the Cake 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 Cake 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 */
1) Download the plugin to /app/plugins/url_cache

2) Put this either in your app_helper
   App::import('Vendor', 'UrlCache.url_cache_app_helper');
   
3) Have your AppHelper extend UrlCacheAppHelper instead of Helper
   class AppHelper extends UrlCacheAppHelper {
   ...
   }

4) Thats it!  Just continue using $html->link as you usually do.
   By default all the cache will be stored in one file.
   You can set the option Configure::write('UrlCache.pageFiles', true) and each page will keep a seperate cache.
   I added this option in the event your site has a ton of unique urls don't want to store them all in one giant cache,
   which would need to be loaded each request.

5) When ever you do new builds/update your routes, you can delete /app/tmp/cache/persistent/cake_core_url_map

url_cache's People

Contributors

josegonzalez avatar mcurry avatar phally avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.