First time here? Check out the FAQ!
0

How to make askbot work with memcached?
 

In the settings.py of production server, I added

 CACHES = {
     'default': {
             'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
            'LOCATION': 'unix:xxx/memcached.sock',
        }
 }

Also added middleware in the file. memcached is started. But when i tried to run askbot in the production mode, it seems like some files, like css file, javascript file, need to be requested from cache. Some links are like: http://xxx.webfactional.com/m/CACHE/js/85190e85e697.js

But it can't be found in the server side. How to configure memcached for the per-site cache?

Many thanks.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
jqy3222089's avatar
17
jqy3222089
asked 12 years ago, updated 12 years ago

Comments

see more comments

1 Answer

0

Do you mean that /CACHE/ in the file path means it should be coming from the memcached? Actually - it does not. There is no connection between the /CACHE/ directory and the memory object caching (memcached or any other - at all).

Directory /CACHE/ will be created in your static files directory by the django-compressor app. You will need to make sure to make that directory writeable by the webserver.

It's just a directory name. If your site is working with that configuration, that means your memcached is fine.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Evgeny's avatar
13.2k
Evgeny
answered 12 years ago, updated 12 years ago
link

Comments

I didn't use that path for the memcached, it was automatically changed into that way when i turned the debug off.

jqy3222089's avatar jqy3222089 (12 years ago)

That path has nothing to do with memcached. What makes you think it is?

Evgeny's avatar Evgeny (12 years ago)

So what should I do when I need to deploy ASKBOT into a production server? Just turn off the debug mode did not work since I have tried this in the server.

jqy3222089's avatar jqy3222089 (12 years ago)
1

You can't see the .css and .js files? Do you have directory CACHE inside the static files directory? If not - please create it and change permissions so that the webserver can write into that directory.

Evgeny's avatar Evgeny (12 years ago)

That's the problem. After creating CACHE directory, it's working now. Many thanks!@Evgeny

jqy3222089's avatar jqy3222089 (12 years ago)

But what was the problem? Can you describe your observation before the fix?

Evgeny's avatar Evgeny (12 years ago)

The problem is that when I switched askbot into production mode, some static files were failed to be loaded. And some of the address were changed into "/m/CACHE/..."(maybe memcached changed this address?), but in the static directory there was no such directory named CACHE, so I need to manually create it.

jqy3222089's avatar jqy3222089 (12 years ago)

/m/CACHE/ has no connection with memcached whatsoever, saying this to you third time:). Most likely webserver process could not create directory CACHE due to insufficient privilege of the effective user of the webserver process.

Evgeny's avatar Evgeny (12 years ago)

@Evgeny: what kind of data will be cached ?

winzer's avatar winzer (12 years ago)

@Evgeny yes, I see now. :>

jqy3222089's avatar jqy3222089 (12 years ago)

@koogua - if you have a question about Memcached - please post it separately. The static files and the directory CACHE are not related to memcached at all. Memcached caches the application data, but directory CACHE contains combined js and css files and it is just a directory on disk like any other.

Evgeny's avatar Evgeny (12 years ago)

I'm having the same problem actually, but my static files are hosted on S3. So it expects the cached CSS, JS etc. to be in the CACHE subfolder on S3. Is this expected? Am I supposed to give permissions to my web server to write to S3? What's the point of creating more new files on S3 though.

kate_r's avatar kate_r (12 years ago)

@kate_r please look at the django-compressor documentation. Askbot may not be supporting offline asset compilation, but you could give it a try. Google for using <strike>django-staticfiles</strike> django-compressor with S3.

Evgeny's avatar Evgeny (12 years ago)

In that case, should I disable caching altogether? If so, could I just remove all the CACHE_ variables from settings.py?

kate_r's avatar kate_r (12 years ago)

err.. I made a mistake - it has to do with django-compressor app and has no connection with caching (like memcached) - at all. Please google django-compressor and Amazon S3.

Evgeny's avatar Evgeny (12 years ago)

yeah, I've figured that out. :) So could you please explain why Askbot currently expects static files to come from a CACHE subfolder, even they're stored externally?

kate_r's avatar kate_r (12 years ago)

django-compressor does this. Please read their documentation.

Evgeny's avatar Evgeny (12 years ago)

Possibly compressor allows to specify custom storage class - maybe you can find one that will store files on S3. Btw, it may also be necessary to use custom file storage for the user-uploaded files in this case.

Evgeny's avatar Evgeny (12 years ago)

From my understanding, offline compression doesn't work with template inheritance though.

kate_r's avatar kate_r (12 years ago)

Try custom storage set by configuration for the compressor, maybe that will work.

Evgeny's avatar Evgeny (12 years ago)

I'll try that. But then, I'm not sure if this has anything to do with the storage class, but if I run python manage.py compress --force, a whole list of errors fire up!

kate_r's avatar kate_r (12 years ago)
see more comments