niccokunzmann / open-web-calendar

Embed a highly customizable web calendar into your website using ICal source links
https://open-web-calendar.quelltext.eu
GNU General Public License v2.0
212 stars 70 forks source link

Allow caching of static files in the browser #439

Open niccokunzmann opened 4 months ago

niccokunzmann commented 4 months ago

We can reduce network traffic by caching a few files in the static directory.

flask probably offers an easy solution to this problem.

GET https://open-web-calendar.hosted.quelltext.eu/css/dhtmlx/dhtmlxscheduler_material.css

cache-control
    no-cache, no-store, must-revalidate
content-disposition
    inline; filename=dhtmlxscheduler_material.css
content-length
    121880
content-type
    text/css; charset=utf-8
date
    Fri, 19 Jul 2024 09:33:00 GMT
etag
    "1721376604.0-121880-2803833627"
expires
    0
last-modified
    Fri, 19 Jul 2024 08:10:04 GMT
pragma
    no-cache


We're using Polar.sh so you can upvote and help fund this issue. We receive the funding once the issue is completed & confirmed by you. Thank you in advance for helping prioritize & fund our work.

Fund with Polar

besque commented 1 month ago

Hey @niccokunzmann, I would love to work on this and I've set it up and running as of now.

I'd like to know what all files you would prefer to have cached.

for example,

{16091921-F529-4AC0-85D0-05B6FC129F65}

these above mentioned file types can be considered for caching

Please let me know if you'd like me to include or remove any types of files from being cached.

Thank You!

niccokunzmann commented 1 month ago

Thanks! Everything in the static folder can be cached regardless of its file type. That is what the folder is for. I do not know which headers are right to set but it would improve the loading time, I think.

This is probably worth looking at:

https://github.com/niccokunzmann/open-web-calendar/blob/34e60d1f68a143356aea9f1a930c1a6507ba4630/open_web_calendar/app.py#L259

besque commented 1 month ago

Hey,

Thank you for that, I've gone ahead and made the required changes to the code so now it should cache all the files in the static folder. And yes I do observe a significant improvement in the load time.

Here's a screenshot comparing the before and after-

before (hosted website): image after :

{BB84DFFE-0BF3-4FED-847C-1984B78C406C}

I'll go ahead and create a PR for this, Thanks for the help!

besque commented 1 month ago

Hey @niccokunzmann ,

I've created the PR, please review and merge it.

Thank you very much!