Hello! I need some help, recently I’ve made my website on my PC with everything working fine, however now that I’ve uploaded it to Dreamhost, the SQL statements I have are actin very weird, inserting data works fine though getting data is the weird part, it works after a really long time, I have a repeating function to grab the results every 10 seconds, sometimes it just doesn’t open. As I was typing this, the queries came in now 10 minutes later. The problem is the function only goes every 10 seconds (Yes I know this for sure). Does anyone know what the issue could be? I can connect to the DB fine using phpMyAdmin, another thing to note is that the MySQL DB is external, not hosted by Dreamweaver, I get the data simply using SELECT * FROM table.
More detail would be helpful. For example, what language is the website written in (PHP, Node, etc), which DH platform (Shared, VPS, etc) and how is the repeating function being invoked? Are there any error messages? I’d expect network timeout or retry errors. Is a new socket connection being opened every 10 seconds, rather than reusing an existing connection? That might run into something like a connection limit, especially if the connections aren’t closed properly.
The language is PHP, DH is shared, the function is being invoked by a simple setTimeout function in a JS script, no error messages, closing and creating a new connection every 10 seconds, I’ll look into that a bit. Though if there are no entries in the table, I get nothing, I add one and then 10 minutes later of saying it has nothing, starts saying the updated table.
Is it possible that the external DB service is limiting lookups from your server IP at 1 per 10min? I’d query them to see if they need to whitelist your DreamHost server requests.
Thanks @Flaming_Knight for the details. My first thought is that maybe you’re running afoul of caching? DH’s servers are setup for production, so this means they behave differently than your local dev environment. In particular, responses are automatically set to be cached (10 minutes for HTML, 30 days for CSS, JS, images, etc). Also, error messages are not displayed on pages, but rather logged to
If you use your browsers dev inspector, you may see the following cache header on you PHP responses. This causes the browser to cache the response for 10 minutes:
If caching is the problem, then you can turn off caching in PHP with something like this (double-check with PHP references):
header("Cache-Control: no-cache, must-revalidate");
Thanks! That does seem to be the problem, on mobile toggling between desktop view and mobile view takes changes immediately