getpelican / pelican

Static site generator that supports Markdown and reST syntax. Powered by Python.
https://getpelican.com
GNU Affero General Public License v3.0
12.55k stars 1.81k forks source link

Blog caching #507

Closed lucassmagal closed 12 years ago

lucassmagal commented 12 years ago

Hello guys,

I have, finally, deployed my blog. I'm still hacking the theme, but almost everything is fine, except one thing: browser page caching.

How are you dealing with it?

justinmayer commented 12 years ago

Hi Lucas. I haven't had any issue with browser page caching, so there hasn't been anything for me to deal with. Why don't you hop onto IRC via either...

... where it will be easier to help you. Thanks!

onlyhavecans commented 12 years ago

Are you referring to, when developing a theme how do deal with the fact that the browser caches artifacts, forcing you to HARD reload every time or not see your changes?

This is the universal developers query and there is many ways of dealing with it. I use a program called coda, which is a web ide that has a debugging browser that never caches. Cheaper solutions include developer plugins for your favorite browser, or debug mode (like in safari) which has a disable caches options

justinmayer commented 12 years ago

No IRC love. Like a jilted paramour, my heart is in tatters. :disappointed:

FWIW, I use Safari in regular, non-debug mode, and all I need to do is a normal page reload to update the cached assets. I serve the files locally via python -m SimpleHTTPServer and http://localhost:8000/ instead of viewing files directly in the browser. (e.g., file:///mysite/index.html)

sigmavirus24 commented 12 years ago

I know that feel @justinmayer. I also always test locally before deploying it with the simple server that python has so I don't encounter this either with Firefox.

onlyhavecans commented 12 years ago

Sorry for trying to be helpful!!! sigh ;p The develop_server.sh script init's both python's simple server and pelican auto-reload in debug mode. I wrote this because those two combined I found perfect for theme development

lucassmagal commented 12 years ago

No, I'm not having problems with browser caching during development, the problem is when the code is deployed... currently I'm using heroku with ruby's Rack TryStatic middleware.

justinmayer commented 12 years ago

Hmm. As the BunnyMan said in his original comment, there's nothing about browser asset caching that's specific to Pelican. Perhaps the Heroku or Rack communities would be better positioned to help.

In any case, this sounds like a Rack config issue. Do you have static asset caching enabled anywhere? Anything like this?

require "rack/contrib/static_cache"
use Rack::StaticCache, [...]
onlyhavecans commented 12 years ago

So you deploy but old content is still being displayed? I've never had or heard of a problem like that before.

I'm inexperienced with heroku so I can't help, sorry.

lucassmagal commented 12 years ago

@tbunnyman , yes, I can only see the new content with a hard reload =S

@justinmayer , no, I'm not aware of these Rack configurations. Is there anyone using Rack to serve a pelican blog or it's just me?

onlyhavecans commented 12 years ago

I know someone other than yourself has mentioned it but no complaints.

honzajavorek commented 12 years ago

I deployed my Pelican to GitHub pages and this also happened to me. Browser cached my statically served pages and I had to perform hard reload to get the newest document. As I generated some little stuff by cron on daily basis (list of events), it was not very nice, because my visitors had seen expired list of events from yesterday until they hardrefreshed the page (but no normal person does this, really). As there is no way to change the way GitHub serves static pages (e.g. HTTP headers, I think you could adjust them to somehow prevent such behaviour, at least for often-changing pages), I finally decided to move it to Heroku - I turned the list of events into a proper, dynamic Python/Flask Heroku app.

lucassmagal commented 12 years ago

@honzajavorek , that's what I'm trying to do now... I'm changing some Ruby/Rack configurations to see what can solve this kind of problem.

So... what's your Flask app? Can you share this code with me?

honzajavorek commented 12 years ago

@lucassmagal I actually completely rewritten the whole thing into normal dynamic app. So it's not a solution for you. I had a list of events generated by cron into a static page. I turned it into full-featured dynamic Flask app with views, the list of events is generated on request now.

lucassmagal commented 12 years ago

@honzajavorek , it seems a interesting approach, even it's not a solution for me, I'm really curious about it.

honzajavorek commented 12 years ago

@lucassmagal Well, look here for the original app: https://github.com/honzajavorek/zitkino Now I am trying to turn it into proper app. It's not done yet, I develop it in https://github.com/honzajavorek/zitkino/tree/standalone-app.

justinmayer commented 12 years ago

I think this discussion has run its course. Issue closed.

eamonnfaherty-productmadness commented 9 years ago

I am having the same issue.

I am deploying to github pages using travisci and I have to hard reload the home page to see the most up to date version.

Is there any solution to this?

justinmayer commented 9 years ago

@eamonnfaherty-productmadness: This doesn't have anything to do with Pelican. Moreover, what you are describing sounds, to me, the way browser caching is designed to work. I don't understand what the perceived problem is.