Skip to content

Commit

Permalink
templates: cache torrent view filelist (nyaadevs#542)
Browse files Browse the repository at this point in the history
* templates: cache torrent view filelist

Using flask-caching, we can add a 1 hour cache to the template
output of a filelist, varying it by the key "filelist" + the
hex infohash of a torrent.

Using a very big filelist as a test, I get a difference in page
load speeds of about a magnitude. (400ms -> 37 ms)

* templates: increase filelist cache to 24 hours
  • Loading branch information
CounterPillow authored and Arylide committed Mar 8, 2019
1 parent 585e1ae commit 6a63ee2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nyaa/templates/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ <h3 class="panel-title">
</div>
</div>

{% cache 86400, "filelist", torrent.info_hash_as_hex %}
{% if files and files.__len__() <= config.MAX_FILES_VIEW %}
<div class="panel panel-default">
<div class="panel-heading">
Expand Down Expand Up @@ -133,6 +134,7 @@ <h3 class="panel-title">
</div>
</div>
{% endif %}
{% endcache %}

<div id="comments" class="panel panel-default">
<div class="panel-heading">
Expand Down

0 comments on commit 6a63ee2

Please sign in to comment.