Ok so I was wondering which one of these 2 methods is better ?
Method 1: query string from database, and directly use file_put_contents()
Method 2: query string from database, use file_get_contents, check if both data are identical from the db and from the file and if not use file_put_contents()
Just want to know which one is a better method for a file that is a main file required for page display on the site ?
and thanks.
Method 1 will be better if the string changes a lot.
Method 2 will be better if the string doesn’t change that often.
It has to do with the fact that reading is faster than writing.
You could consider putting a value in the database which says if the string content is already saved, if not: