Doubt over cached files

0

I'm building a system in php, and I'm creating the design material that will be used in the system. I created 2 files, 1st Materia.js and 2º Material.css.

Well in these files I'll put all CSS and JS. I will call the file on the login screen and the logged page.

My question is every time the logged in page loads the bowser will it download the files or will it load it from the cache?

Will this leave the system heavy?

I'm following the way that Materializer works.

    
asked by anonymous 05.08.2016 / 13:35

1 answer

2

This depends on whether the server caches resources or not, this can be seen in one of the response headers parameters of the requested server, in case facebook is:

Cache-Control: "private, no-cache, no-store, must-revalidate"

This means that it does not cache anything, it always renews itself, and it's private (in case something is in the cache is just for me). Here and here are those better explained.

To configure the cache of your server in php you can do:

header("Cache-Control: private, no-cache, must-revalidate");

Or in html you can also, exs:

<meta http-equiv="Cache-control" content="public">
<meta http-equiv="Cache-control" content="private">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache-control" content="no-store">

Or htaccess ex:

<filesMatch ".(css|jpg|jpeg|png|gif|js|ico)$">
Header set Cache-Control "max-age=2628000, public"
</filesMatch>

In this case, this htaccess would server for your case, caching resources with these extensions. But note that this could be set in php too

An aspect not directly related to the question, but has to do with performance, it is also important to do gzip to resources, you can not .htaccess do:

<IfModule mod_deflate.c>
    <FilesMatch "\.(html|php|txt|xml|js|css)$">
        SetOutputFilter DEFLATE
    </FilesMatch>
</IfModule>

To answer your question, you can control this on the server and configure it with your preferences, here you have plus one reference.

    
05.08.2016 / 13:57