Leveraging HTTP caching
Instead of only server-side caching implementation you can use client-side caching via specific HTTP-headers.
In this recipe, we will cover full-page caching on the basis of the Last-Modified
and ETag
headers.
Getting ready
Create a new yii2-app-basic
application using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
Create and run migration as follows:
<?php use yii\db\Migration; class m160308_093233_create_example_tables extends Migration { public function up() { $this->createTable('{{%article}}', [ 'id' => $this->primaryKey(), 'created_at' => $this->integer()->unsigned()- >notNull(), 'updated_at' => $this->integer()->unsigned()->notNull(), 'title' => $this->string()->notNull(), 'text' => $this->text()->notNull(), ]); } public...