php - How to add browser cache in Laravel 5? -


i wish add browser caching laravel application.

i have used elixir versioning tool so: https://laravel.com/docs/5.2/elixir#versioning-and-cache-busting

however, according google pagespeed insights, files still not caching , instead got message:

setting expiry date or maximum age in http headers static resources instructs browser load downloaded resources local disk rather on network.

i think may because need manually add cache headers?

yes need set cache-control , expires in http header static resources, google pagespeed message not show up.

since you're using elixir versioning tool, can safely set expires of js/css files 1 week.

the way depends on web server using.

if using apache, may put following code in .htaccess or config file of virtual website.

<filesmatch "\.(js|css)$">   expiresactive on   expiresdefault "access plus 1 weeks" </filesmatch> 

be sure enable mod_expires apache module!

with same syntax, can set cache rules .html, .jpg, .png files , on, speed page loading.

if using nginx, there similar ways solve problem, may follow this tutorial


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -