what is browser caching?
browser stores static files css.js,.jpg in local to avoid downloading it from server every time a page refreshes.
How browser know which type of content & how long?
then it commes to http headers so browser & server communicates with these.
caching headers like
if modified since
not only browsers proxy severs also respect it.
caching validity for static resources
css js png jpg etc won’t change so frequently. settings it minimum upto 7 days or 365 days max.
content type html/TXT
Tell browser not to cache or cache for 1 hour.
based on your content changing frequency.
fastcgi cache, w3tc plugin we generally set for 1 hour html content.
disabling it also better. user may not read the again 1 hour. If you date it uses won’t notice changes because it’s served from local.
he has to clear browser cache or shift+reload to clear specific page.
enabling browser cache in wordpress by w3tc?
html & XML
if modified since
added to your htaccess in apache
In nginx a file will be created nginx.conf
rules will be added there , but you have to link
the directory conf file to server block by include directive.
then reload nginx
nginx -s reload to effect the changes.
Don’t forget to Gzip access encoding Gzip
by default it will be,
you can enable by htaccess mid deflate in apache,
Gzip by default added in nginx.conf
it saves lot of bandwidth. Ex your page size 7MB. after Gzip it will be 2-3MB.
you need 2.5x cpu,ram for serving same content without Gzip or brotil.
nginx add header last modified, if modified since won’t works?
unless you set a variable it cannot print last modified, & if modified since.
you simply place
in http & server, location blocks.
better results place it location block where content differentiate,
we need different cache approaches for different content types.
enable browser caching in apache server level
modules to verify
enabling browser caching in nginx?
place directives in any of the location block
if_modified_since exatct | before |off;
default value off
Last_modified exact; default exact; (you won’t need to add unless yiu disable it or customize)
etag on; default off;
expires 30d; default off;
add_header cache-control public; must-revaliate,no transform etc ( additional to expiry to controlling whoom to cache proxy or browser )
expires 30d; //place this in static content location block.