You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to serve static files from Laravel routes. Ex: /test
I know I can set eTag/CacheControl on route middleware for /test, but first request is slow (PROBLEM) ... second will be cached.
Requirements
I am NOT allowed to hack Nginx conf to serve this route/test as static content
The issue
Serving /hello.css through NGINX is 20x faster than /test Laravel route.
Template
<head>
...
<!--- Serve CSS from a Laravel route --><linkrel="stylesheet" href="/test" /><!-- Through ordinary NGINX --><linkrel="stylesheet" href="/hello.css" /></head>
hello.css
body {
color: red
}
web.php
Route::get('/test', function () {
returnresponse('body { color: red }')->withHeaders([
'Content-Type' => 'text/css'
]);
});
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goal
I am trying to serve static files from Laravel routes. Ex: /test
I know I can set
eTag/CacheControl
on route middleware for/test
, but first request is slow (PROBLEM) ... second will be cached.Requirements
I am NOT allowed to hack Nginx conf to serve this route
/test
as static contentThe issue
Serving
/hello.css
through NGINX is 20x faster than/test
Laravel route.Template
hello.css
web.php
What I have tried ... but no luck
Screenshots
Responses
/test response
/hello.css response
Beta Was this translation helpful? Give feedback.
All reactions