i am using python 2.7,django=1.5 and tastypie v0.12.1 when i am hit 1 recourse data is then caching is happing
class BranchResource(ModelResource):
class Meta:
collection_name="data"
queryset = Branch.objects.all()
resource_name = 'branch'
authorization = Authorization()
limit = 0 #(unlimted)
filtering = {
"branch_flag": ALL,
"branch_name":('exact', 'startswith','istartswith',),
"cid":ALL,
}
cache = SimpleCache(timeout=1000)
is caching is working when i hit
http://127.0.0.1:8000/v0/branch/1
but in when i getting all data then caching is not working
http://127.0.0.1:8000/v0/branch/
that time caching not work is direct hit db and getting data from database
The problem is with your server configuration I guess. Please edit your server configuration file as given below (if it is nginx) vi /etc/nginx/sites-enabled/your-site-name and add the following line of code in the file
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache cache;
}
}
Second thing which you have to do is create a directory/folder called cache in your project
Finally go to nginx.conf and edit the file like this
vi /etc/nginx/nginx.conf
go to line no 80
proxy_cache_path yourworkspace/projectname/cache keys_zone=cache:1m max_size=2m;
DONE!!! Now Caching will work fine