{"id":94,"date":"2016-03-08T01:30:27","date_gmt":"2016-03-07T20:00:27","guid":{"rendered":"http:\/\/madhurendra.com\/?p=94"},"modified":"2016-03-08T01:43:08","modified_gmt":"2016-03-07T20:13:08","slug":"website-optimization-cache-cache-cache","status":"publish","type":"post","link":"https:\/\/madhurendra.com\/website-optimization-cache-cache-cache\/","title":{"rendered":"Website Optimization – Cache Cache Cache !"},"content":{"rendered":"

You must have heard about cache in web (caches are everywhere in computer science), most times you find it really buggy when changes aren’t reflected as soon as you make them.
\nFor sites with small traffic these things are buggy – but they contribute a major in server traffic when you have a million hits even a thousand.<\/p>\n

From server to browser what what we can cache ? & why to cache ?<\/p>\n

    \n
  1. Enabling code caching – if you are running nodejs server etc things are in your favour because process is running & its already using existing variables still you should make sure that you don’t fetch\/store too much data – you should implement cache in your code AND<\/em> if you are using php or similar scripting language – let me tell you things are really slow – each time you make a request if apache – php thread is spawned, nginx a new thread along with socket is created – PHP code is compiled to opcode & then executed, That’s a lot – You can use opcaches or APC for optimizing php script. Alternatives may follow other languages.<\/li>\n
  2. Caching static content – Since static content are not changing every other minute or day – most files are kept as it is for years!, you should tell your server that these contents are rarely changed – Check nginx cache config<\/a> & Apache cache config<\/a><\/li>\n
  3. Setting cache expiry header – This one is definitely under you control doesn’t matter if you are in shared hosting or running own server. You should send cache expiry header with all static content. Basically cache expiry tells browser to keep the file for next n days – though it is not strict , browsers send head request to see if file is changed or not.<\/li>\n
  4. Offline Storage\/WebSQL\/Offline Application – Yes, You read it right – You can use offline storage to cache insensitive data on users browser only – this will reduce load on server & data transferred – you can even cache js & css. <\/li>\n
  5. CDN – Content delivery networks can also help you a lot in caching – since libraries like jquery, bootstrap etc are so common today if you use CDN your page might not need to load JS & CSS, This is because that file might already exists in browser cache when some other website requested it. You should Thank to other guy – someday other guy will thank you. <\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"

    You must have heard about cache in web (caches are everywhere in computer science), most times you find it really buggy when changes aren’t reflected as soon as you make them. For sites with small traffic these things are buggy – but they contribute a major in server traffic when you have a million hits … <\/p>\n

    Continue reading<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[6],"tags":[22,20,21,18,19],"class_list":["post-94","post","type-post","status-publish","format-standard","hentry","category-server","tag-apache","tag-cache","tag-nginx","tag-server","tag-website-optimization","item-wrap"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pciGs2-1w","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/posts\/94","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/comments?post=94"}],"version-history":[{"count":4,"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/posts\/94\/revisions"}],"predecessor-version":[{"id":98,"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/posts\/94\/revisions\/98"}],"wp:attachment":[{"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/media?parent=94"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/categories?post=94"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/tags?post=94"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}