I'm wondering the best way to handle push notifications of comments that my site's users will send to each other.
When a new comment is submitted it will obviously be stored in my database. However, i'd like to also store each user's comments in memcache or as session data (whatever is considered best?) such that every time the user visit my site/refreshes the page, they can quickly get their unread notifications and not hit my database.
One way I thought of doing this was upon the user receiving a push notification, to send an AJAX request back to the server to update their memcache/session data.
The problem is what to do if the user isn't logged in or isn't currently using the site. Will the AJAX request still be sent even though the user isn't there to "receive" it? Or will the AJAX request "wait" and happen as soon as the user revisit the site? Is handling notifications in this way even a good idea in the first place?