Headers don’t get set in Laravel 5.6 - development

Headers don’t get set in Laravel 5.6

I’m using Laravel 5.6.

I’m trying to cache my css/js files. The way I’m doing it is using a middleware.

  public function handle($request, Closure $next, $guard = null)
  {

    $request->header('Cache-Control', 'max-age=86400, public');
    $request->header('X-www-test-header', 'test-value');

    return $next($request);
  }

And wrapping basically every route in this middleware. This seems like a really bad idea from where I’m standing but to be perfectly honest I can’t find another way to do it(any suggestions are welcome). But that’s not the problem.

The problem is that my headers don’t make thru.

enter image description here

I’ve also tried setting the headers via .htaccess

  <IfModule mod_headers.c>
    <filesmatch ".(ico|flv|jpg|jpeg|png|gif|css|swf)$">
  Header set Cache-Control "max-age=2678400, public"
  </filesmatch>
    <filesmatch ".(html|htm)$">
  Header set Cache-Control "max-age=7200, private, must-revalidate"
  </filesmatch>
    <filesmatch ".(pdf)$">
  Header set Cache-Control "max-age=86400, public"
  </filesmatch>
  <FilesMatch ".(js|css)$">
  ExpiresActive On
    ExpiresDefault "access plus 1 weeks"
  </FilesMatch>

That doesn’t work either.

I’m honestly not sure what the problem is. Either laravel is somehow rewriting all the headers or apache or something.

Literally any pointing in the right direction is appreciated.



from Laravel Questions and Answers https://laravelquestions.com/php/headers-dont-get-set-in-laravel-5-6/
via Lzo Media

Comments

Popular posts from this blog

ng-show doesn’t work correct with value boolean

Using PHP and MySQL data to generate PDF letters like in MS Word mailmerge functionality - development

ng-include of inline SVG does not display gradient except in Chrome