For AJAX, recommend using dictionary object to store LastData, as you can use the AJAX.tag as your key. This allows you to create a single catch all event for any number of requests and tags, rather than having to create a specific event and condition for each tag/request.
If you need history or logs, you can add a for each key event (with an incrementing counter) to push to an array. An additional step would be to add a comparison to check if the current key actually updated from the last pushed data in the array before pushing whatever is in the dictionary to the array (prevent duplicates/unecessary update).
Sorry again for not having any ideas for websocket, I've never touched it and not familiar with the mechanics.