laravel - Laravel 5.3 中的 ESI 标签

标签 laravel laravel-5.3 varnish esi

对于我目前正在处理的 Laravel 5.3 项目,应根据特定上下文动态构建面包屑。由于我们需要在这个项目上使用 Varnish,因此我尝试使用 ESI 标签。

我已经设置了一个路由来呈现面包屑并在 routes/web.php 中按如下方式返回它:

Route::get('breadcrumbs', 'BreadcrumbController@showBreadcrumb');

这是 Controller 的样子:
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class BreadcrumbController extends Controller
{
    public function showBreadcrumb(Request $request)
    {
        return 'Breadcrumb';
    }
}

在我的模板中,我的 ESI 标签定义如下:
<esi:include src="{{ url('breadcrumbs') }}" />

现在,当我加载页面时,我会在应呈现 ESI 标记的位置看到文本“重定向到/breadcrumbs”。显然,我然后重定向到/breadcrumbs 并查看 Controller 的输出。

如何停止这种重定向行为并让 Laravel 返回所需的输出?

最佳答案

原来,我在Web路由上使用的本地化中间件导致了重定向。它重定向了没有语言前缀的任何路由。

我正在使用mcamara/laravel-localization。从面包屑路径中删除中间件解决了该问题。

关于laravel - Laravel 5.3 中的 ESI 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41701389/

相关文章:

php - Laravel 城市关系外键

php - 在 laravel 中创建自定义注册表单

mysql - laravel where子句中的子查询

laravel-5 - Laravel 5.3 - Omnipay Paypal Express 不返回成功消息

linux - Varnishncsa 截断引用

webserver - Varnish 配置文件在哪里?

laravel - AWS ElastiCache Redis 无法从 Laravel nad 从 redis-cli 连接

mysql - SQLSTATE[23000] : Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

php - Laravel eager load 功能限制

wordpress - Varnish 未启动语法错误