Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda