Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Updated http_cache/* articles to Symfony 4#8682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
weaverryan merged 3 commits intosymfony:4.0fromjaviereguiluz:update_http_cache
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletionshttp_cache.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,6 +125,8 @@ finely tuned via a set of options you can set by overriding the
method::

// src/CacheKernel.php
namespace App;

use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;

class CacheKernel extends HttpCache
Expand All@@ -141,10 +143,9 @@ method::
For a full list of the options and their meaning, see the
:method:`HttpCache::__construct() documentation <Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache::__construct>`.

When you're in debug mode (either because your booting a ``debug`` kernel, like
in ``index.php`` *or* you manually set the ``debug`` option to true), Symfony
automatically adds an ``X-Symfony-Cache`` header to the response. Use this to get
information about cache hits and misses.
When you're in debug mode (the second argument of ``Kernel`` constructor in the
front controller is ``true``), Symfony automatically adds an ``X-Symfony-Cache``
header to the response. Use this to get information about cache hits and misses.

.. _http-cache-symfony-versus-varnish:

Expand DownExpand Up@@ -218,7 +219,7 @@ The *easiest* way to cache a response is by caching it for a specific amount of
use Symfony\Component\HttpFoundation\Response;
// ...

public functionindexAction()
public functionindex()
{
// somehow create a Response object, like by rendering a template
$response = $this->render('blog/index.html.twig', []);
Expand Down
16 changes: 8 additions & 8 deletionshttp_cache/esi.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,14 +62,14 @@ First, to use ESI, be sure to enable it in your application configuration:

.. code-block:: yaml

#app/config/config.yml
# config/packages/framework.yaml
framework:
# ...
esi: { enabled: true }

.. code-block:: xml

<!--app/config/config.xml -->
<!-- config/packages/framework.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/symfony"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand All@@ -87,7 +87,7 @@ First, to use ESI, be sure to enable it in your application configuration:

.. code-block:: php

//app/config/config.php
// config/packages/framework.php
$container->loadFromExtension('framework', array(
// ...
'esi' => array('enabled' => true),
Expand All@@ -104,7 +104,7 @@ independent of the rest of the page.
// ...
class DefaultController extends Controller
{
public functionaboutAction()
public functionabout()
{
$response = $this->render('static/about.html.twig');
// set the shared max age - which also marks the response as public
Expand DownExpand Up@@ -195,7 +195,7 @@ of the master page.
// ...
class NewsController extends Controller
{
public functionlatestAction($maxPerPage)
public functionlatest($maxPerPage)
{
// ...
$response->setSharedMaxAge(60);
Expand All@@ -220,14 +220,14 @@ that must be enabled in your configuration:

.. code-block:: yaml

#app/config/config.yml
# config/packages/framework.yaml
framework:
# ...
fragments: { path: /_fragment }

.. code-block:: xml

<!--app/config/config.xml -->
<!-- config/packages/framework.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand All@@ -245,7 +245,7 @@ that must be enabled in your configuration:

.. code-block:: php

//app/config/config.php
// config/packages/framework.php
$container->loadFromExtension('framework', array(
// ...
'fragments' => array('path' => '/_fragment'),
Expand Down
6 changes: 3 additions & 3 deletionshttp_cache/validation.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,7 +66,7 @@ To see a simple implementation, generate the ETag as the md5 of the content::

class DefaultController extends Controller
{
public functionhomepageAction(Request $request)
public functionhomepage(Request $request)
{
$response = $this->render('static/homepage.html.twig');
$response->setEtag(md5($response->getContent()));
Expand DownExpand Up@@ -131,7 +131,7 @@ header value::

class ArticleController extends Controller
{
public functionshowAction(Article $article, Request $request)
public functionshow(Article $article, Request $request)
{
$author = $article->getAuthor();

Expand DownExpand Up@@ -190,7 +190,7 @@ exposing a simple and efficient pattern::

class ArticleController extends Controller
{
public functionshowAction($articleSlug, Request $request)
public functionshow($articleSlug, Request $request)
{
// Get the minimum information to compute
// the ETag or the Last-Modified value
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp