Skip to content

Commit

Permalink
Fixing cache issues, optimizing public page query.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksergeant committed Aug 27, 2010
1 parent 967b778 commit 08d2a40
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 30 deletions.
2 changes: 1 addition & 1 deletion gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
logfile = "./logs/gunicorn.log" # Name of the log file
loglevel = "info" # The level at which to log
pidfile = ".gunicorn.pid" # Path to a PID file
workers = 1 # Number of workers to initialize
workers = 4 # Number of workers to initialize
umask = 0 # Umask to set when daemonizing
user = None # Change process owner to user
group = None # Change process group to group
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-e git://github.com/django/[email protected]#egg=django
-e git+http://github.com/benoitc/gunicorn.git#egg=gunicorn
-e git+http://github.com/benoitc/gunicorn.git@0.11.0#egg=gunicorn
-e svn+http://django-pagination.googlecode.com/svn/trunk/#egg=django-pagination
-e git+http://github.com/django-extensions/django-extensions.git#egg=django-extensions
-e hg+http://bitbucket.org/jespern/django-piston#egg=django-piston
Expand Down
1 change: 1 addition & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.comments',
'django.contrib.sites',
'django_authopenid',
'django_extensions',
'piston',
Expand Down
22 changes: 0 additions & 22 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,6 @@
<div id="header">
<div class="frame clearfix">
<div id="logo-container">{% block logo %}<a href="/{{ request.user.username }}"><img id="logo" src="/media/images/logo.png" alt="Snipt" title="Snipt" /></a>{% endblock %}</div>
<div id="header-ads">
{% comment %}
<div style="float: left; display: block;">
<a style="display: block; width: 100px; margin: 0 0 0 11px !important;" href="http://riffer.org" title="Riffer - The guitarist's definitive Q &amp; A site"><img src="/media/images/riffer.png" title="Riffer - The guitarist's definitive Q &amp; A site" alt="Riffer - The guitarist's definitive Q &amp; A site" /></a>
</div>
{% endcomment %}
<script type="text/javascript">
//<![CDATA[
Vertical1236429 = false;
ShowAdHereBanner1236429 = true;
RepeatAll1236429 = false;
NoFollowAll1236429 = true;
BannerStyles1236429 = new Array(
"a{display:block;font-size:11px;color:#5C5C5C;font-family:verdana,sans-serif;margin:0 4px 10px 0;text-align:center;text-decoration:none;overflow:hidden;}",
"img{border:0;clear:right;}",
"a.adhere{color:#5C5C5C;font-weight:bold;font-size:12px;border:1px solid #292929;background:transparent;text-align:center;}",
"a.adhere:hover{background:transparent;color:#FFF;}"
);
document.write(unescape("%3Cscript src='"+document.location.protocol+"//s3.buysellads.com/1236429/1236429.js?v="+Date.parse(new Date())+"' type='text/javascript'%3E%3C/script%3E"));
//]]>
</script>
</div>
<div id="twitter">
<a href="http://twitter.com/lionburger"><img id="blink" src="{{ MEDIA_URL }}images/mr-tweet-blind.png" alt="" title="" /></a>
<a href="http://twitter.com/lionburger"><img id="mr-tweet" src="{{ MEDIA_URL }}images/mr-tweet.png" alt="Kick ass twitter bird by http://thedesignsuperhero.com" title="Kick ass twitter bird by http://thedesignsuperhero.com" /></a>
Expand Down
6 changes: 3 additions & 3 deletions templates/home_user.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
{% if mine %}<a class="add-snipt right" href="#">add snipt</a>{% endif %}
<h1 style="margin-bottom: 35px;">
{% if not mine and not key and not request.user.is_authenticated and not public %}
<a href="/public">Public snipts</a> &raquo;
<a href="/public">Latest 100 public snipts</a> &raquo;
{% endif %}
{% if slug %}
<a href="/{% if mine %}{{ request.user.username }}{% else %}{{ context_user.username }}{% endif %}">
Expand All @@ -230,7 +230,7 @@ <h1 style="margin-bottom: 35px;">
{%if not public %}
{{ context_user.username }}'s
{% else %}
Public
Latest 100 public
{% endif %}
{% endif %}
snipts</a> &raquo; {{ tag }} <a href="{{ request.path }}/feed" title="The latest {% if public %}public {% endif %}{% if tag %}{{ tag }} {% endif %}snipts{% if context_user and not public %} from {{ context_user }}{% endif %}."><img src="/media/images/rss.png" style="margin-left: 4px; vertical-align: -2px;" alt="The latest {% if public %}public {% endif %}{% if tag %}{{ tag }} {% endif %}snipts{% if context_user and not public %} from {{ context_user }}{% endif %}." title="The latest {% if public %}public {% endif %}{% if tag %}{{ tag }} {% endif %}snipts{% if context_user and not public %} from {{ context_user }}{% endif %}." /></a>
Expand All @@ -241,7 +241,7 @@ <h1 style="margin-bottom: 35px;">
{%if not public %}
{{ context_user.username }}'s
{% else %}
Public
Latest 100 public
{% endif %}
{% endif %}
snipts <a href="{{ request.path }}/feed" title="The latest {% if public %}public {% endif %}{% if tag %}{{ tag }} {% endif %}snipts{% if context_user and not public %} from {{ context_user }}{% endif %}."><img src="/media/images/rss.png" style="margin-left: 4px; vertical-align: -2px;" alt="The latest {% if public %}public {% endif %}{% if tag %}{{ tag }} {% endif %}snipts{% if context_user and not public %} from {{ context_user }}{% endif %}." title="The latest {% if public %}public {% endif %}{% if tag %}{{ tag }} {% endif %}snipts{% if context_user and not public %} from {{ context_user }}{% endif %}." /></a>
Expand Down
3 changes: 1 addition & 2 deletions urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.views.generic.simple import direct_to_template
from django.views.decorators.cache import cache_page
from django.utils.translation import ugettext as _
from django.conf.urls.defaults import *
from django.contrib.auth.views import *
Expand Down Expand Up @@ -50,5 +49,5 @@
)

urlpatterns += patterns('',
(r'^(?P<user>[^/]+)?/?(?P<slug>tag/[^/]+)?/?(?P<snipt_id>[^/]+)?/?(all)?$', cache_page(dispatcher, 60 * 15)),
(r'^(?P<user>[^/]+)?/?(?P<slug>tag/[^/]+)?/?(?P<snipt_id>[^/]+)?/?(all)?$', dispatcher),
)
2 changes: 1 addition & 1 deletion views.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def user_page(request, user, slug, feed=False):
elif not public:
snipts = Snippet.objects.filter(user=context_user.id, public='1').order_by('-created')
else:
snipts = Snippet.objects.filter(public='1').order_by('-created')
snipts = Snippet.objects.filter(public='1').order_by('-created')[:100]

# Compile the list of tags that this user has used.
if mine:
Expand Down

0 comments on commit 08d2a40

Please sign in to comment.