Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

195
Visualizações
How can I get around caching policy when using Laravel to generate CSS and Javascript?

I am using Laravel to generate files for what would otherwise be inline JS and CSS.

The web.php configuration is:

Route::get('/js/words.js', function() {
    $words = Word::get();

    return response()->view('words', compact('words'))->header('Content-Type', 'text/javascript');
});

When I deploy this to the server initially everything is fine. But then, when I add a simple CSS/JS caching policy to the Nginx configuration, the generated CSS/JS breaks.

The Nginx configuration is:

location ~* \.(css|js)$ {
    expires 30d;
}

Does anybody else do this to avoid inline CSS/JS, and if so, how do you enable caching without breaking the generated files?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I've used it like this

location ~* \.(?:css|js)$ {
   expires 365d;
   access_log off;
   add_header Cache-Control "public";
}

and make sure to restart the nginx server

sudo systemctl restart nginx

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda