We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36541
    • 222 Posts
    I encounter some strange problems with downloading static resources.

    I've got a bunch of images and zips as static resources, which were created some 6 months ago. They downloaded fine, when I created them. They all had "attachment" content disposition. They were not available to the public, as the parent was unpublished. Now, when I wanted to publish them as a part of a section, they fail to download.

    I tried all sorts of modifications to those resources -- changing names, changing files, re-publishing, changing content type and disposition, duplicating them -- to no avail. The thumbnails for images display OK (they are fed with +content:phpthumbof... tag) but the target image doesn't download. The browser sends a request and it has no response.

    Strange thing is, when I create a new static resource with the same files as the old ones, it works! It downloads without problems. Well, almost. Although the images show and zips are written do disk there is a report in MODX errror log:

    (ERROR @ /index.php) Could not retrieve data to cache for resource 146

    This error appears despite of the resource being downloaded, despite the success or failure.

    Additionally in Opera I observe the download fail (I mean its status in download manager) although it downloads ok. If I choose to open the image with Opera it displays but the request continues and hangs. Also, although the popup for action displays a correct download size, the download manager doesn't display it. Nothing of this happens when downloading via direct link from web server.

    I'm running latest dev branch from Git on:

    * Ubuntu Server 10.04 x86_64
    * Lighttpd 1.4.26
    * PHP Version 5.3.2, FastCGI
    * MySQL 5.1.41

    Browsers I tested in:

    * Opera/9.80 (X11; Linux x86_64; U; pl) Presto/2.9.168 Version/11.50
    * Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Ubuntu/11.04 Chromium/13.0.782.218 Chrome/13.0.782.218 Safari/535.1
    * Mozilla/5.0 (X11; Linux x86_64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2

    Why the old static resources don't download correctly while the new do?
      This is the web: the only thing you know about who will come is that you don't know who will come.
      • 3749
      • 24,544 Posts
      Is the template for the static resources set to "empty" ?
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 36541
        • 222 Posts
        Sorry for replying so late. I did not get notification email.

        As to your question: No, the template is not set to "empty". Depending on section static resources use custom templates, which provide fields for additional meta data. Those templates, however, are empty ie. they do not contain any code. This worked fine before.

        Following your question, I investigated templates used by those static resources and discovered the new resources -- those which do download -- were using default template as I had an error in FC setting the proper template. After playing around with them I discovered that static resources using the "empty" template do download, while those using a custom empty template do not. Thus I filled my custom template with:
        [[*content]]
        and it worked. They do download now.

        It looks like there was a change in code in the meantime, which I haven't notice. But this behavior is not consistent to me. Since the "empty" template does work why other empty does not?
          This is the web: the only thing you know about who will come is that you don't know who will come.
        • Are these binary content types? Or are these Static Resources just producing HTML?
            • 36541
            • 222 Posts
            They are all binary: PNGs, PDFs, ZIPs and MP3s.
              This is the web: the only thing you know about who will come is that you don't know who will come.
              • 6038
              • 228 Posts
              Yes!
              I encountered the same issue using v2.2.2.
              I created static resources with custom Content Type:
              Name: PDF
              mime: application/pdf
              extension: .pdf
              binary: yes
              I set up static resources with 'blank' template, linked the static resource to a pdf file, set the content type as PDF, left the disposition as inline, and in the front end when the link to this resource was clicked they downloaded fine.
              Later, to add meta data for the resources, I created my own 'blank' template to which I attached TVs. I discovered later that the delivery of PDF files was no longer working because of this change in template. In the error log I had the message: "Could not retrieve data to cache for resource XX". The HTTP response headers showed 200 OK but size was basically zero. The solution was to add [[*content]] to my custom 'blank' template, which made the pdfs work again.
              • Well... using 2.2.8, and using the original Base Template, which does have the [[*content]] tag, I'm getting this same caching error. Files do download as expected. [ed. note: sottwell last edited this post 10 years, 6 months ago.]
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 45206
                  • 32 Posts
                  Hello,

                  In a fresh new install in 2.3.3, I've come to the same conclusion of christianhanvey.
                  In order to download a PDF static resource, this resource must have the "empty" template or a template with at least the [[*content]] tag.
                  Is this a known issue ?

                  Thanks for your response ?
                    • 38878
                    • 255 Posts
                    I can confirm on modxcloud v2.3.3 as well. Only way to get rid of these errors for me was to set the resource to uncached.
                    • Confirmed 2.4.4 (and probably 2.5 but I haven't tested the site throwing errors with it yet) - Static resources, specifically PDFs throw errors unless set to uncached. If this is the solution we're going with, I feel like something should be noted in the RTFM or perhaps some kind of automatic setting to uncached when the resource type is changed.

                      Anyone have other static resource types that are throwing errors other than PDFs?
                        Frogabog- MODX Websites in Portland Oregon
                        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                        Having server issues? These guys have MODX Hosting perfected - SkyToaster