What client data should I capture in my webapi from client requests?

时间:2015-06-30 13:39:30

标签: c# facebook cookies web asp.net-web-api

Mid-level .net developer here but noob when it comes to public facing (potentially high-traffic) websites.

Doing a little research I noticed a lot of public/high-traffic websites like facebook or even stackoverflow will store ~10 (sometimes more) cookies and I can only imagine these are used for tracking my usage, but I don't know this for sure.

Can anybody tell me or point me to a guide for what data I should be capturing from each client interaction with my api outside of the intended post/put body data? What the significance of said data would be?

And also if anyone knows why so many different cookies? Is there a certain design pattern being followed to only save certain type of data in certain cookies, etc.

1 个答案:

答案 0 :(得分:1)

Unless you have a very specific need for collecting persistent data from the client (often cookies), don't collect anything. Collect only what you need. Sites like facebook are plugged into a dozen ad networks and they all want to track you across different sites in their network. They use cookies for this.

You can still do some basic metrics based on the standalone requests themselves. If you want user tracking, consider looking into an authentication method for your api. With authenticated users, you can set permissions to certain parts of your API, tailor your responses, and keep the data persistent across even different devices of one user. Then you won't need to store tons of variables in a cookie, and you won't be held hostage to their cache.