I was wondering how much searches could an user do if I made an ajax search bar? Would it count as a hit since it needs to retrieve data from the server?
The hits limit is 50k so around that many (depends on how many hits your website is at). I don’t recommend you do this on free hosting because this can get you suspended very fast.
You can set up a system where it sends AJAX request after the user doesn’t type for 5 seconds.
Every AJAX request counts as a hit. Every request also uses an entry process, CPU power, a database connection and so on. So you need to be careful when doing something that could generate a lot of requests.
Having AJAX in general is fine, if you only send a request when someone actually hits a search button, it doesn’t really matter if you use AJAX or just render an entirely fresh page. Search-as-you-type can also be OK, as long as you have a reasonable debounce so you don’t send too many requests.
Anything that constantly refreshes in the background is a bad idea.
I was planning on using an XML file as a “database”, but I really want to use JS entirely not a mixture of JS and PHP.
Depending on the size of the dataset, you could just download the entire “database” and handle searching in the browser. Then you don’t need any AJAX at all.
Especially if the database is a JSON file and you hook in something like Lunr to handle searching.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.