From 37b64051874b9c7ece1edcd1721ad822032d0d72 Mon Sep 17 00:00:00 2001 From: Kniest Jordan Date: Sun, 7 Jan 2018 06:11:59 +0100 Subject: [PATCH] Updated readme and changelog --- LICENSE | 2 +- changelog.md | 6 ++++++ readme.md | 30 ++++++++++-------------------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/LICENSE b/LICENSE index 04a665d..085c0ab 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2017 Jordan Kniest +Copyright Jordan Kniest Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the diff --git a/changelog.md b/changelog.md index 0e91345..0f0589a 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [1.0.3] - 2018-01-07 +### Changed +- GET parameters are now considered in the cache generation +- Offical PHP 7.2 support + ## [1.0.2] - 2017-11-21 ### Changed - Sites are not being cached if they do not have a 200 status code @@ -21,3 +26,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. [1.0.1]: https://github.com/jkniest/HTMLCache/compare/1.0.0...1.0.1 [1.0.2]: https://github.com/jkniest/HTMLCache/compare/1.0.1...1.0.2 +[1.0.3]: https://github.com/jkniest/HTMLCache/compare/1.0.2...1.0.3 diff --git a/readme.md b/readme.md index d301c92..931edf6 100644 --- a/readme.md +++ b/readme.md @@ -10,7 +10,7 @@ This package is made for you if you have a lot of static pages (or pages that do And it is highly customizable: You can even cache the same page for every user different, allowing that you can cache for example their account page or dashboard without worrying that another user can see these cached pages. -__One benefit against much other html caches:__ It will also cache the pages based on language, and (optionally) user id. And if there are special cases (for example a special GET-parameter) that needs to be used to generate multiple versions of the same page, the middleware can be easily modified. +__One benefit against much other html caches:__ It will also cache the pages based on language, and (optionally) user id. And if there are special cases (for example a specific session value) that needs to be used to generate multiple versions of the same page, the middleware can be easily modified. --- @@ -131,7 +131,7 @@ In a few cases the pages will not be cached: ## Configuration -You can nearly configure anything inside the `.env` file. +You can configure nearly anything inside the `.env` file. ### Enable / Disable cache @@ -191,21 +191,21 @@ This will create a new file in your project: `config/htmlcache.php`. There you c ## Clear cache -The html cache package uses the default laravel cache helpers. So you simple run the artisan command to clear the cache: +The html cache package uses the default laravel cache helpers. So you can run the artisan command to clear the cache: ```shell php artisan cache:clear ``` -This will remove every cached version of this plugin (and also of everything else). It is recommended to put this in your deployment workflow (for example in the deployment script in forge or as an deployment hook in envoyer) +This will remove every cached version of this plugin (and also everything else). It is recommended to put this in your deployment workflow (for example in the deployment script in forge or as a deployment hook in envoyer) --- ## Override middlware -It is possible to override the middleware. So you could override the cache-key generation. In this short tutorial we will add another field to the cache key generation (the post id). +It is possible to override the middleware. So you could override the cache-key generation. In this short tutorial we will add another field to the cache key generation (the current weekday). -Let's say you have a forum and you can access each page with a get parameter. For example: `http://my-forum.dev?page=3`. In the default implementation all pages would share the same cached results (which means that the pagination isn't working anymore). +Let's say you have a dashboard and all data on this dashboard will only update every weekday. In the default implementation you would have to set a maximum cache time (for example 1 day) but you can't be sure that the cache was generated exactly on 0am. The simplest solution would be to override the middleware and extends the cache-key generation. @@ -232,10 +232,11 @@ Now we can override any methods. The method `getCacheKey` handles the generation $prefix = config('htmlcache.prefix'); $locale = app()->getLocale(); - $page = str_replace('/', '_', trim($page, '/')); + $page = md5(trim($page, '/')); if (config('htmlcache.user_specific')) { $id = Auth::check() ? Auth::id() : -1; + return "{$prefix}{$page}_{$locale}_{$id}"; } @@ -250,9 +251,7 @@ Let's implement our own (in the HtmlCache middleware that we just created): { $key = parent::getCacheKey($page); - if (request('page') !== null) { - $key .= '_' . request('page'); - } + $key .= date('D'); return $key; } @@ -273,18 +272,9 @@ Of course you can always override any other method (like the `Handle` method its --- -## Roadmap - -These are features that are planned for to upcoming versions. If you have any suggestion please let me know via issues or e-mail me at `contact@jkniest.de` - -### Version 1.1.0 -- Add native pagination support (so that the page GET parameter will also be cached) - ---- - ## License -Copyright 2017 Jordan Kniest +Copyright Jordan Kniest Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the