Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeroen Oostwouder 100 posts 296 karma points
    Feb 01, 2018 @ 08:12
    Jeroen Oostwouder
    0

    Exclude a specific contenttype from cache (umbraco.config)

    Hi there,

    I'm having some trouble with a site. It has a lot of nodes. Every sent contactform gets also saved as a contentitem (for backup/history)

    Now, the umbraco.config file is almost 20MB, and most of it's contents are these sent contact-forms.

    They are only available in the backend, so I want to exclude them from the cache. Is there a easy way to exclude a specific contenttype from getting cached? So my umbraco.config will get a normal filesize again?

  • Steven Harland 78 posts 518 karma points c-trib
    Feb 01, 2018 @ 08:42
    Steven Harland
    100

    Hi Jeroen,

    Currently there isn't a way to do this. It's been discussed but nothing has made it into the core:

    What I would suggest for now is simply unpublishing the parent node of these items which will remove them from the cache. This may have implications, however, if you are retrieving these items from the cache anywhere in the application (using the UmbracoHelper for instance).

    When the form is submitted I'm guessing it's creating an IContent and calling SaveAndPublish. I'm not sure what happens when you call SaveAndPublish if the parent node is unpublished. I would guess that the publish has no effect, but it's probably worth changing this to just Save anyway.

    Longer term you probably want to change the implementation. Using Umbraco content items for volatile data is not recommended: https://our.umbraco.org/documentation/reference/Common-Pitfalls/#using-umbraco-content-items-for-volatile-data

    Have a look at using PetaPoco (shipped with Umbraco) to save these to a custom database table. You could then use either Fluidity or UI-O-Matic to make the data available in the backoffice.

  • Jeroen Oostwouder 100 posts 296 karma points
    Feb 01, 2018 @ 08:49
    Jeroen Oostwouder
    1

    Thank you for your quick answer.

    I haven't thought about unpublishing the content. It's never used on the front-end, so only the SaveAndPublish() will need possible adjustment.

    I will have a look at PetaPoco, thank you.

Please Sign in or register to post replies

Write your reply to:

Draft