Your problem could have been caused by any number of things:
If your system drive is too full, then that will certainly cause slowness. Deleting caches won’t help you, as they will just fill up again.
Old, incompatible software — particularly those with background processes that run at launch — could also be a factor.
However, one of the reasons that Apple excludes a particular model from the supported list on a new OS is that the “user experience” is not up to Apple’s standards. In other words, the model isn’t able to sustain the performance levels that Apple expects. It may be possible to run Sonoma on your Mac if you’re doing web browsing, email and Office apps; but development work is another matter.
If you are an app developer, then you can’t really use a 10-year-old computer. You don’t say which model, but the 13″ 2015 had only 2 cores.