Which will be faster and best option? Page will load faster with fwrite or memcached cached function? I need to store some functions in cache, they will not update very often, so need only to read it. Which one will be best option?
Memcache, by about 1000x
Memcached works by storing objects in RAM, if you were to fwrite the data it would be stored on a disk so you'd get disk performance. If possible, always go for Memcached over disk/file storage and make sure you change your memcached config to use a decent amount of ram (By default it'll only use 1GB so if you've got a decent server you can upgrade it a bit, I wouldn't give it more than 75% of your ram but a good chunk).