ActionRetro / 68k-news

Source for the 68k.news site
GNU General Public License v3.0
92 stars 18 forks source link

Added cache database and User-Agent HTTP header #2

Open asivery opened 3 years ago

asivery commented 3 years ago

This should improve the page loading speed and prevent rate limiting on the news servers. I also encountered 403 Forbidden errors caused by the missing User-Agent HTTP header - this should fix them. The database functionality can be turned off using the USE_CACHE define in article.php. If the database ever becomes corrupted, it will be deleted and recreated. If that fails, the script will just ignore it and load the page without caching it. The cached articles will automatically get deleted after a period of 24 hours.

ActionRetro commented 3 years ago

Thanks for this! What would I need to do server-side to get this code going?

asivery commented 3 years ago

You only need to install the sqlite3 extension for php. For me (Ubuntu 20.04) I had to install php7.4-sqlite3. Other than that, the database should create itself automatically (The program should have write permissions to the database file defined in cache_database.php). You might need to also prevent users from accessing cache_database.php and the database itself.