Skip to content

Added cache database and User-Agent HTTP header - #2

Open
asivery wants to merge 1 commit into
ActionRetro:mainfrom
asivery:main
Open

Added cache database and User-Agent HTTP header#2
asivery wants to merge 1 commit into
ActionRetro:mainfrom
asivery:main

Conversation

@asivery

@asivery asivery commented Apr 12, 2021

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Owner

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

@asivery

asivery commented Apr 12, 2021

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants