diff --git a/html/bt/torrent_cache.php b/html/bt/torrent_cache.php
new file mode 100755
index 0000000000..7201d90171
--- /dev/null
+++ b/html/bt/torrent_cache.php
@@ -0,0 +1,57 @@
+isValid($file)) throw new IllegalArgumentException("File was not accepted by the server for tracking.");
+
+// Everything's fine let's lookup the .torrent in the cache if needed:
+$cache_args = "file=".$file."&modtime=".$fileModTime;
+$cacheddata=get_cached_data(TORRENT_CACHE_TTL,$cache_args);
+if ($cacheddata){ //If we have got the data in cache
+ $torrent = unserialize($cacheddata); // use the cached data
+} else { //if not do queries etc to generate new data
+ for ($i=0; $iensureSHA1Loaded();
+ db_init();
+ $torrent->register();
+ set_cache_data(serialize($torrent),$cache_args); //save data in cache
+};
+
+header("Content-type: application/x-bittorrent");
+header("Content-Disposition: attachment; filename=\"".basename($file).".torrent\"");
+
+echo $torrent->toEncoded();
+?>
\ No newline at end of file