Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajax request from cached routes (pages) are not working #38

Open
abalakrishnan opened this issue Aug 10, 2017 · 2 comments
Open

Ajax request from cached routes (pages) are not working #38

abalakrishnan opened this issue Aug 10, 2017 · 2 comments

Comments

@abalakrishnan
Copy link

Hi,

I have implemented the latest version 0.3.0 package in laravel 5.2.X and normal pages working fine , but none of the ajax requests are working after implementing this.
When i comment this line in Kernal 'Barryvdh\HttpCache\Middleware\CacheRequests', ajax works but no cache is then generated in the storage. Please help me on this.

the below steps i did
in Kernal
protected $middleware = [
...all existing lines////
'Barryvdh\HttpCache\Middleware\CacheRequests',
];

protected $routeMiddleware = [
......all existing lines////
'ttl' => \Barryvdh\HttpCache\Middleware\SetTtl::class,
];

then in app.php i have added 'Barryvdh\HttpCache\ServiceProvider',

then in my routes i did like below because i need in only few pages

Route::get('/mypage', [
'middleware' => 'ttl:86400', 'uses' => 'MyController@mymethod'
]);

@ctf0
Copy link

ctf0 commented Aug 20, 2017

for me it was related to clearing the cache when user is logged-in/ logged-out / register as atm the http cache doesnt support user contexts without a 3rd party package. #42

but sometimes you would still get an error about the csrf, and the solution would be adding the 'Barryvdh\HttpCache\Middleware\CacheRequests' at the end of web group

'web' => [
    \App\Http\Middleware\EncryptCookies::class,
    \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
    \Illuminate\Session\Middleware\StartSession::class,
    \Illuminate\Session\Middleware\AuthenticateSession::class,
    \Illuminate\View\Middleware\ShareErrorsFromSession::class,
    \App\Http\Middleware\VerifyCsrfToken::class,
    \Illuminate\Routing\Middleware\SubstituteBindings::class,
    
    'Barryvdh\HttpCache\Middleware\CacheRequests',
],

it have to be after VerifyCsrfToken middleware

#41

@abalakrishnan
Copy link
Author

This i have already tried but that time i didn't cleared cache, will give a try after clearing the cache after placing the above line in web middleware group

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants