google chrome - The files served by my Apache Server are not being saved on browser cache -


i have installed , configured apache server virtualhost serves images.

when load page images on browser second time (the images should on cache after first time page loaded), browser doesnt images (or files) cache, , think should.

what wrong? using google chrome, , when load other web other server cache works, think have problem apache, not sure.

thank much.

the response video-segment played dash player.

response headers:

accept-ranges:bytes content-length:194431 date:wed, 09 mar 2016 07:42:07 gmt etag:"2f77f-52acd33f8b167" last-modified:tue, 02 feb 2016 17:55:12 gmt server:apache/2.4.18 (unix) openssl/1.0.2e php/7.0.2 status:200 

after doing that:

expiresactive on  # set caching on media files 1 year (forever?) <filesmatch "\.(mp4|m4s)$"> expiresdefault "access plus 3600 seconds" header set cache-control "public" header set content-type "video/mp4" header set vary "host" header set access-control-allow-origin "*" </filesmatch> 

the headers are:

accept-ranges:bytes access-control-allow-origin:* cache-control:public content-length:194431 content-type:video/mp4 

but doesnt save on cache, mean, when reload web or video, not cache should.

you not including cache-control headers telling browser cache resources. spec unclear how handle browsers choose not cache unless explicitly told to.

you need include apache config (assuming including mod_expiries module):

expiresactive on  # set caching on media files 1 week <filesmatch ".([ii][cc][oo]|[gg][ii][ff]|[jj][pp][gg]|[jj][pp][ee][gg]|[pp][nn][gg]|[ff][ll][vv]|[pp][dd][ff]|[ss][ww][ff]|[mm][oo][vv]|[mm][pp]3|[ww][mm][vv]|[pp][pp][tt])$">    expiresdefault a604800    header append cache-control "public" </filesmatch>  # set caching on font files 6 months <filesmatch ".([ee][oo][tt]|[tt][tt][ff]|[ss][vv][gg]|[ww][oo][ff][ff]|[ww][oo][ff][ff]2)$">    expiresdefault 15552000    header append cache-control "public" </filesmatch> 

which produce header this:

cache-control:max-age=10800, public 

i've written blog post on if want more details: https://www.tunetheweb.com/performance/http-performance-headers/caching/


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -