Download the PHP package glaivepro/cachepage without Composer

On this page you can find all versions of the php package glaivepro/cachepage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cachepage

CachePage

Laravel middleware for full page caching.

Table of Contents

How do I get this in my app?

Binding it to your app

Skip this section if you are using package discovery which is default for recent versions of Laravel.

Firt of all you have to register the service provider.

Open config/app.php and find the providers key. Add this line to the array.

If you will need to adjust the behaviour of the package, you have to publish the configuration file according to your application. Just execute this artisan command:

php artisan vendor:publish --provider="GlaivePro\CachePage\CachePageServiceProvider"

And you will have the config/cachepage.php file to change whenever this manual tells you to adjust something in the configuration.

How do I use it?

Middleware

Add the gpcachepage middleware to a route and all responses will be cached for the configured time. By default it's 5 minutes, but you can change it in the configuration.

The response will be cached using Laravels Cache functionality you should configure it. It will be keyed by requests url and tagged with gpcachepage tag (if your cache driver supports tagging).

You can specify time if you want to. For example, to cache a page for two minutes:

Or make a group of routes that cache their responses for 5 minutes:

For further advice regarding usage of middlewares you should read the Laravel documentation about middlewares.

User-specific caching

Sometimes the page should be different for different users. For example, you might want to display the users name at top - you will want users to see their own name there, not the cached one, right?

You can do it like this:

Specifying time in this case is unavoidable. The key for caching will be something like id=153&url=http://mypage.com.

If you want to key by users role or some other field (or related field), you can try to pass them like this:

The middleware will then try to get a value from Auth::user()->role->name.

If you only want to cache pages for guests, use the key NULL like this and caching will be disabled for authenticated users:

Other concerns

Can I skip it?

If you want to skip caching and just view a freshly made page, pass skipcache=true as a HTTP parameter, for example:

http://mypage.com/contacts?skipcache=true

You can also use 1 instead of true if you prefer it.

If you are afraid that users might abuse this, you can disable this functionality in configuration like this:

How to clear the cache?

If you want to clear the cached page that you are seeing, specify a true clearcache in the HTTP request:

http://mypage.com/contacts?clearcache=1

The cache for page that you are seeing will be erased. However, if you are using user-specific caching, other users caches will not be reset. If you don't want this to be possible, you can disable it in the config:

If you update something like main menu or make changes to a page that you want all users to see, you can clear all of the cache using flushcache in the url.

http://mypage.com/contacts?flushcache=1

This functionality is dangerous as someone can easily clear your cache all the time therefore it is disabled by default. If you decide to use it, you have to enable it in the configuration like this:

Beware! If possible, we use tags for caching. However, if you are using caching driver that does not support tagging, this flushing might clear all of your applications cache.

When should I use it?

First of all, decide the maximum allowable caching time for a page. How often does the page change? How soon do you want the changes to be visible? Is it ok that a page will refresh once every minute? Once every 10 minutes? Once a week?

When you know the time, try to guess how many users will use a single cache. For example, if you cache a page for 2 minutes, how many users will view it during the time? If the page will receive 100 hits during the 2 minutes, sure it's worth caching. However some old article or a privacy policy page might be viewed less than once every 2 minutes, so no point caching those for 2 minutes as no users would use the cached version.

If you are using user-specific caching, take into account that as well. If each of your logged-in users see a different page, will they actually do enough hits to make the caching worth it?

Changelog

It's here.

License

This package is licensed under the MIT license.


All versions of cachepage with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
laravel/framework Version >=5.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package glaivepro/cachepage contains the following files

Loading the files please wait ....