English 中文(简体)
tracking download completions from a website/cdn
原标题:

I have a Drupal website where users are clicking on a link that initiates a file download from a content delivery network (CDN). A script is tracking the number of users who click the link to begin the download process. I m looking for suggestions on how I might track the number of users who successfully complete the download process.

最佳回答

If you only need the number of completed downloads, just grab the raw logs from your CDN and run them through a log analysis tool. Most CDNs provide daily access logs as a standard service. The bigger players can do hourly logs or better.

The best solution will depend on your CDN, so talk to them if you haven t already. However, here s how I ve done it in the past.

To each protected download URL generated, append a unique id for the user who made the request. A typical CDN download URL might contain an expiry time and a hash to prevent tampering. You ll want to check with your CDN first to make sure you pick a variable name that doesn t clash with their API. In our case we agreed on a prefix of ign_* (meaning ignore.)

Before:

http://cdn.example.com/path/to/file.ext?e=EXPIRES&h=HASH

After:

http://cdn.example.com/path/to/file.ext?e=EXPIRES&ign_u=USERID&h=HASH

Example (download link for user 1234):

http://cdn.example.com/path/to/file.ext?e=1356088260&ign_u=1234&h=39341385b9d99730646d927f620111e1

Now when you download your raw logs, each entry can be associated with one of your users simply by parsing the query string. From here you can do everything from counting the number of completed downloads, to implementing per-user download reports.

In our case, we had logs available every 15 minutes and I automated the fetching and processing to enable byte-level per-user download quotas.

One thing to keep in mind, if you re going to be processing the logs yourself, is to group HTTP 206 partial entries together. Particularly if you re interested in the "number of completed downloads."

问题回答

暂无回答




相关问题
How to upload and download file from a server using C#

I am developing a webpage in that the user can download their Resume for Edit. So I have a link to download the article. I use the following code for download. DataTable dt = user.getUserDetails(2); ...

Detecting PDF Download

I have recently added functionality for generating pdf reports to a web application. However the reports can be quite large and take some time to show the pdf download dialog. I want to show a spinner ...

Writing file to users giving sporadic error in IE

I have a very interesting issue with only specific IE implementations. I have an ASPX page that is used to write files down to the user, as part of the process the page uses the following code to ...

PHP - List of Excel files to download from Intranet Site?

I have a intranet site running PHP 5 that needs to list a folder containing only Excel files. Ideally the user needs to be able to input some search criteria (ie date) and the files would be filtered ...

Determine total size of SVN directory/trunk

Is there a way to count/calculate the total size of a svn directory if you were to checkout a revision? I have limited internet downloads so I need to know how big something is before I go and ...

Scala and html: download an image (*.jpg, etc) to Hard drive

I ve got a Scala program that downloads and parses html. I got the links to the image files form the html, Now I need to transfer those images to my hard drive. I m wondering what the best Scala ...

Downloading file with wxHTTP?

Im really stumped. Im using the wxHTTP class in wxWidgets to try and download two files. The first request succeeds but the second one fails when wxHTTP->GetInputStream is called. Between downloads, ...

热门标签